Skip to content

Commit d9c6e2d

Browse files
committed
fix: Do not interpret special characters (e.g ", `) from context variables
1 parent 687329f commit d9c6e2d

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@ jobs:
2828
token: ${{ secrets.SCRIBD_SLACK_GENERIC_TOKEN_PUBLIC }}
2929
channel: test-release-notification
3030
message: <https://scribd.com|Custom message>
31+
test-custom-message-with-special-characters:
32+
runs-on: ubuntu-22.04
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v3
36+
with:
37+
token: ${{ secrets.GITHUB_TOKEN }}
38+
- name: Run action
39+
uses: ./
40+
with:
41+
token: ${{ secrets.SCRIBD_SLACK_GENERIC_TOKEN_PUBLIC }}
42+
channel: test-release-notification
43+
message: <https://scribd.com|Special characters + "quotes" + `backtick`>
3144
test-overwrite-repository:
3245
runs-on: ubuntu-22.04
3346
steps:

action.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ runs:
3535
echo "color=warning" >> $GITHUB_OUTPUT
3636
fi
3737
38-
if [ ! -z "${{ inputs.message }}" ]; then
39-
message="${{ inputs.message }}"
40-
elif [ ! -z "${{ github.event.head_commit.message }}" ]; then
38+
if [ ! -z '${{ inputs.message }}' ]; then
39+
message='${{ inputs.message }}'
40+
elif [ ! -z '${{ github.event.head_commit.message }}' ]; then
4141
# get commit message from `push` trigger
42-
commit_message=$(echo "${{ github.event.head_commit.message }}" | head -n 1)
42+
commit_message=$(echo '${{ github.event.head_commit.message }}' | head -n 1)
4343
message="<https://github.com/${{ inputs.repository }}/commit/${{ github.sha }}|$commit_message>"
4444
elif git rev-parse --is-inside-git-dir > /dev/null 2>&1; then
4545
# get commit message from the current git directory to support `workflow_dispatch` trigger
@@ -91,7 +91,7 @@ runs:
9191
},
9292
{
9393
"title": "Commit Message",
94-
"value": "${{ steps.fields.outputs.message }}",
94+
"value": ${{ toJSON(steps.fields.outputs.message) }},
9595
"short": false
9696
}
9797
]

0 commit comments

Comments
 (0)