Skip to content

ci: sanitize PR name in Slack notification messages like <&test> #81

ci: sanitize PR name in Slack notification messages like <&test>

ci: sanitize PR name in Slack notification messages like <&test> #81

Workflow file for this run

name: PR Slack Notification
on:
pull_request:
types: [opened, ready_for_review]
jobs:
notify-slack:
name: Notify Slack
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Sanitize PR title
id: sanitize
run: |
RAW_TITLE="${{ github.event.pull_request.title }}"
ESCAPED_TITLE=$(echo "$RAW_TITLE" \
| sed 's/&/\&amp;/g' \
| sed 's/</\&lt;/g' \
| sed 's/>/\&gt;/g')
echo "safe_title=$ESCAPED_TITLE" >> "$GITHUB_OUTPUT"
- name: Post to a Slack channel
uses: slackapi/slack-github-action@v1
with:
channel-id: eng-execution-mrs
slack-message: ":github: `${{ github.repository }}` <${{ github.event.pull_request.html_url }}|${{ steps.sanitize.outputs.safe_title }}>"
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN }}