From fa8682a35e4e26771f8aa3e9d6bfc5210c264fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Dubois?= Date: Fri, 11 Oct 2024 13:32:04 +0200 Subject: [PATCH] fix(plone-package-test-notify): escape command on notification message --- plone-package-test-notify/action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/plone-package-test-notify/action.yml b/plone-package-test-notify/action.yml index 0d23337..e0a28c5 100644 --- a/plone-package-test-notify/action.yml +++ b/plone-package-test-notify/action.yml @@ -68,14 +68,16 @@ runs: - name : Send notification on Mattermost if: ${{ inputs.MATTERMOST_WEBHOOK_URL != '' }} run: | + ESCAPED_COMMAND=$(echo ${{ inputs.TEST_COMMAND }} | sed 's/\\/\\\\/g') JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" - MESSAGE="Test has run successfully. ([Repository: ${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}), Branch: ${{ github.ref_name }}, [View commit on GitHub](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}), Test command: ${{ inputs.TEST_COMMAND }}, Python version: ${{ inputs.PYTHON_VERSION }}) [Click here to see job on GitHub]($JOB_URL)" + MESSAGE="Test has run successfully. ([Repository: ${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}), Branch: ${{ github.ref_name }}, [View commit on GitHub](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}), Test command: $ESCAPED_COMMAND, Python version: ${{ inputs.PYTHON_VERSION }}) [Click here to see job on GitHub]($JOB_URL)" curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }} shell: bash - name : Send failure notification on Mattermost if: ${{ failure() && inputs.MATTERMOST_WEBHOOK_URL != '' }} run: | + ESCAPED_COMMAND=$(echo ${{ inputs.TEST_COMMAND }} | sed 's/\\/\\\\/g') JOB_URL="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" - MESSAGE="Error : Test has failed. ([Repository: ${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}), Branch: ${{ github.ref_name }}, [View commit on GitHub](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}), Test command: ${{ inputs.TEST_COMMAND }}, Python version: ${{ inputs.PYTHON_VERSION }}) [Click here to see job on GitHub]($JOB_URL)" + MESSAGE="Error : Test has failed. ([Repository: ${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}), Branch: ${{ github.ref_name }}, [View commit on GitHub](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}), Test command: $ESCAPED_COMMAND, Python version: ${{ inputs.PYTHON_VERSION }}) [Click here to see job on GitHub]($JOB_URL)" curl -i -X POST -H 'Content-Type: application/json' -d "{\"text\": \"$MESSAGE\"}" ${{ inputs.MATTERMOST_WEBHOOK_URL }} shell: bash \ No newline at end of file