Skip to content

Commit

Permalink
fix: Do not interpret special characters (e.g ", `) from context vari…
Browse files Browse the repository at this point in the history
…ables
  • Loading branch information
helenff committed Apr 21, 2023
1 parent 687329f commit d9c6e2d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ jobs:
token: ${{ secrets.SCRIBD_SLACK_GENERIC_TOKEN_PUBLIC }}
channel: test-release-notification
message: <https://scribd.com|Custom message>
test-custom-message-with-special-characters:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run action
uses: ./
with:
token: ${{ secrets.SCRIBD_SLACK_GENERIC_TOKEN_PUBLIC }}
channel: test-release-notification
message: <https://scribd.com|Special characters + "quotes" + `backtick`>
test-overwrite-repository:
runs-on: ubuntu-22.04
steps:
Expand Down
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ runs:
echo "color=warning" >> $GITHUB_OUTPUT
fi
if [ ! -z "${{ inputs.message }}" ]; then
message="${{ inputs.message }}"
elif [ ! -z "${{ github.event.head_commit.message }}" ]; then
if [ ! -z '${{ inputs.message }}' ]; then
message='${{ inputs.message }}'
elif [ ! -z '${{ github.event.head_commit.message }}' ]; then
# get commit message from `push` trigger
commit_message=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
commit_message=$(echo '${{ github.event.head_commit.message }}' | head -n 1)
message="<https://github.com/${{ inputs.repository }}/commit/${{ github.sha }}|$commit_message>"
elif git rev-parse --is-inside-git-dir > /dev/null 2>&1; then
# get commit message from the current git directory to support `workflow_dispatch` trigger
Expand Down Expand Up @@ -91,7 +91,7 @@ runs:
},
{
"title": "Commit Message",
"value": "${{ steps.fields.outputs.message }}",
"value": ${{ toJSON(steps.fields.outputs.message) }},
"short": false
}
]
Expand Down

0 comments on commit d9c6e2d

Please sign in to comment.