slack-notify #3375
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
| # THIS FILE WAS AUTOMATICALLY GENERATED BY KRES, PLEASE DO NOT EDIT. | |
| # | |
| # Generated on 2026-05-21T11:52:49Z by kres 44d3d02. | |
| "on": | |
| workflow_run: | |
| workflows: | |
| - default | |
| - weekly | |
| - grype-scan-cron | |
| types: | |
| - completed | |
| name: slack-notify | |
| permissions: | |
| pull-requests: read | |
| jobs: | |
| slack-notify: | |
| runs-on: | |
| group: generic | |
| if: github.event.workflow_run.conclusion != 'skipped' | |
| steps: | |
| - name: Get PR number | |
| id: get-pr-number | |
| if: github.event.workflow_run.event == 'pull_request' | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # version: v9.0.0 | |
| with: | |
| script: | | |
| const prs = await github.rest.pulls.list({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| head: `${context.payload.workflow_run.head_repository.owner.login}:${context.payload.workflow_run.head_branch}`, | |
| state: 'all', | |
| sort: 'updated', | |
| direction: 'desc', | |
| per_page: 1, | |
| }) | |
| if (prs.data.length > 0) { | |
| core.setOutput('pull_request_number', prs.data[0].number) | |
| } | |
| - name: Slack Notify | |
| uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # version: v3.0.3 | |
| with: | |
| method: chat.postMessage | |
| payload: | | |
| { | |
| "channel": "ci-all", | |
| "text": "${{ github.event.workflow_run.conclusion }} - ${{ github.repository }}", | |
| "icon_emoji": "${{ github.event.workflow_run.conclusion == 'success' && ':white_check_mark:' || github.event.workflow_run.conclusion == 'failure' && ':x:' || ':warning:' }}", | |
| "username": "GitHub Actions", | |
| "attachments": [ | |
| { | |
| "blocks": [ | |
| { | |
| "fields": [ | |
| { | |
| "text": "${{ github.event.workflow_run.event == 'pull_request' && format('*Pull Request:* {0} (`{1}`)\n<{2}/pull/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, steps.get-pr-number.outputs.pull_request_number, github.event.workflow_run.display_title) || format('*Build:* {0} (`{1}`)\n<{2}/commit/{3}|{4}>', github.repository, github.ref_name, github.event.repository.html_url, github.sha, github.event.workflow_run.display_title) }}", | |
| "type": "mrkdwn" | |
| }, | |
| { | |
| "text": "*Status:*\n`${{ github.event.workflow_run.conclusion }}`", | |
| "type": "mrkdwn" | |
| } | |
| ], | |
| "type": "section" | |
| }, | |
| { | |
| "fields": [ | |
| { | |
| "text": "*Author:*\n`${{ github.actor }}`", | |
| "type": "mrkdwn" | |
| }, | |
| { | |
| "text": "*Event:*\n`${{ github.event.workflow_run.event }}`", | |
| "type": "mrkdwn" | |
| } | |
| ], | |
| "type": "section" | |
| }, | |
| { | |
| "type": "divider" | |
| }, | |
| { | |
| "elements": [ | |
| { | |
| "text": { | |
| "text": "Logs", | |
| "type": "plain_text" | |
| }, | |
| "type": "button", | |
| "url": "${{ github.event.workflow_run.html_url }}" | |
| }, | |
| { | |
| "text": { | |
| "text": "Commit", | |
| "type": "plain_text" | |
| }, | |
| "type": "button", | |
| "url": "${{ github.event.repository.html_url }}/commit/${{ github.sha }}" | |
| } | |
| ], | |
| "type": "actions" | |
| } | |
| ], | |
| "color": "${{ github.event.workflow_run.conclusion == 'success' && '#2EB886' || github.event.workflow_run.conclusion == 'failure' && '#A30002' || '#FFCC00' }}" | |
| } | |
| ] | |
| } | |
| token: ${{ secrets.SLACK_BOT_TOKEN_V2 }} |