Skip to content

Commit

Permalink
chore(CI): escape PR title for slack webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
ForsakenHarmony committed May 14, 2024
1 parent 7f3a75d commit 44acaf7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
24 changes: 24 additions & 0 deletions .github/workflows/escape.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: escape

on:
push:
branches: ['canary']
pull_request:
types: [opened, synchronize]

jobs:
escape:
name: escape
runs-on: ubuntu-latest
steps:
- name: escape PR title in js
env:
PR_TITLE: ${{ github.event.pull_request.title }}
shell: bash
run: |
node -e 'console.log(`title=${JSON.stringify({ title: process.env.PR_TITLE })}`)'
- name: escape PR title via expression
shell: bash
run: |
echo ${{ toJSON({ title: github.event.pull_request.title }) }}
10 changes: 9 additions & 1 deletion .github/workflows/retry_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ jobs:
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt >= 3 && !github.event.workflow_run.head_repository.fork }}
runs-on: ubuntu-latest
steps:
- name: escape PR title
id: title
env:
PR_TITLE: ${{ github.event.workflow_run.display_title }}
shell: bash
run: |
node -e 'console.log(`title=${JSON.stringify(process.env.TITLE)}`)' >> "$GITHUB_OUTPUT"
- name: send webhook
uses: slackapi/slack-github-action@v1.25.0
with:
Expand All @@ -42,7 +50,7 @@ jobs:
# (through slightly hacky means).
payload: |
{
"commit_title": "${{ github.event.workflow_run.display_title }}",
"commit_title": ${{ steps.title.outputs.title }},
"commit_url": "github.com/${{ github.repository }}/commit/${{ github.event.workflow_run.head_sha }}",
"workflow_run_url": "github.com/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/attempts/${{ github.event.workflow_run.run_attempt }}"
}
Expand Down

0 comments on commit 44acaf7

Please sign in to comment.