Skip to content

Commit

Permalink
fix(plone-package-test-notify): escape command on notification message
Browse files Browse the repository at this point in the history
  • Loading branch information
remdub committed Oct 11, 2024
1 parent d4fe782 commit fa8682a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions plone-package-test-notify/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit fa8682a

Please sign in to comment.