Skip to content

Fix JSON escaping in Slack notifications #211

Fix JSON escaping in Slack notifications

Fix JSON escaping in Slack notifications #211

name: Slack Notifications
on:
issues:
types: [opened]
pull_request_target:
types: [opened]
permissions:
contents: read
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send issue notification to Slack
if: github.event_name == 'issues'
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL_ISSUE }}
webhook-type: incoming-webhook
payload: |
{
"action": ${{ toJSON(github.event.action) }},
"url": ${{ toJSON(github.event.issue.html_url) }},
"title": ${{ toJSON(github.event.issue.title) }}
}
- name: Send pull request notification to Slack
if: github.event_name == 'pull_request_target'
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL_PR }}
webhook-type: incoming-webhook
payload: |
{
"action": ${{ toJSON(github.event.action) }},
"url": ${{ toJSON(github.event.pull_request.html_url) }},
"title": ${{ toJSON(github.event.pull_request.title) }}
}