Handle 404 file not found responses from persistFiles API #1218
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Post PR to Slack | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - converted_to_draft | |
| - ready_for_review | |
| - reopened | |
| - closed | |
| pull_request_review: | |
| types: | |
| - submitted | |
| env: | |
| CONFIG: | | |
| { | |
| "opened": { | |
| "icon": "${{ github.event.pull_request.draft && '📝' || '🆕' }}", | |
| "status": "${{ github.event.pull_request.draft && 'opened as draft' || 'opened' }}" | |
| }, | |
| "converted_to_draft": { | |
| "icon": "📝", | |
| "status": "converted to draft" | |
| }, | |
| "ready_for_review": { | |
| "icon": "👀", | |
| "status": "ready for review" | |
| }, | |
| "reopened": { | |
| "icon": "🔄", | |
| "status": "reopened" | |
| }, | |
| "submitted": { | |
| "icon": "${{ github.event.review.state == 'approved' && '✅' || '💬' }}", | |
| "status": "${{ github.event.review.state == 'approved' && 'code review approved' || 'code review comments' }}" | |
| }, | |
| "closed": { | |
| "icon": "${{ github.event.pull_request.merged && '🚀' || '🗑️' }}", | |
| "status": "${{ github.event.pull_request.merged && 'merged' || 'closed' }}" | |
| } | |
| } | |
| jobs: | |
| notify: | |
| name: Slack notify | |
| runs-on: ubuntu-24.04 | |
| if: ${{ !contains(github.event.pull_request.head.ref || github.head_ref || github.ref, 'dependabot/') }} | |
| steps: | |
| - name: Build Slack JSON | |
| uses: actions/github-script@v7 | |
| id: payload | |
| if: github.event.action != 'submitted' || github.event.review.state == 'approved' | |
| env: | |
| ACTION_ICON: ${{ fromJSON(env.CONFIG)[github.event.action].icon }} | |
| ACTION_STATUS: ${{ fromJSON(env.CONFIG)[github.event.action].status }} | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const title = ${{ toJson(github.event.pull_request.title) }} | |
| const username = ${{ toJson(github.event.pull_request.user.login) }} | |
| const profileUrl = ${{ toJson(github.event.pull_request.user.html_url) }} | |
| const { pull_request } = context.payload | |
| const { owner, repo } = context.repo | |
| // Format as Slack mrkdwn | |
| const titleFormatted = `<${pull_request.html_url}|*${title}* #${pull_request.number}>` | |
| const profileFormatted = `<${profileUrl}|@${username}>` | |
| // Payload output is JSON encoded | |
| return { | |
| channel: '${{ vars.SLACK_CHANNEL_ID }}', | |
| blocks: [ | |
| { | |
| type: 'section', | |
| text: { | |
| type: 'mrkdwn', | |
| text: `${owner}/*${repo}*: ${titleFormatted} by ${profileFormatted} ${{ env.ACTION_ICON }} ${{ env.ACTION_STATUS }}` | |
| } | |
| } | |
| ], | |
| unfurl_links: false, | |
| unfurl_media: false | |
| } | |
| - name: Post to Slack | |
| uses: slackapi/slack-github-action@v2.1.1 | |
| if: github.event.action != 'submitted' || github.event.review.state == 'approved' | |
| with: | |
| method: chat.postMessage | |
| token: ${{ secrets.SLACK_BOT_TOKEN }} | |
| payload: ${{ steps.payload.outputs.result }} |