This action provides the summary of workflow run.
Here is a workflow to send the summary of workflow run to Slack using slackapi/slack-github-action.
name: slack-notification
on:
workflow_run:
types:
- completed
branches:
- main
jobs:
failure:
if: github.event.workflow_run.conclusion == 'failure'
runs-on: ubuntu-latest
steps:
- uses: int128/workflow-run-summary-action@v1
id: summary
- uses: actions/github-script@v7
id: body-json
with:
script: return process.env.body
env:
body: |
@${{ github.actor }} Workflow <${{ github.event.workflow_run.html_url }}|${{ github.event.workflow_run.name }}> is ${{ github.event.workflow_run.conclusion }}.
```
${{ steps.summary.outputs.annotation-messages }}
```
- if: steps.summary.outputs.cancelled == 'false' && steps.summary.outputs.skipped == 'false'
uses: slackapi/slack-github-action@v2
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: your-channel-id
blocks:
- type: section
text:
type: mrkdwn
text: ${{ steps.body-json.outputs.result }}When this action is run on a workflow_run event, it inspects the target workflow run.
Otherwise, it inspects the current workflow run.
| Name | Default | Description |
|---|---|---|
token |
github.token |
GitHub token |
| Name | Description |
|---|---|
annotation-messages |
Annotation messages related to the workflow run |
annotation-failure-messages |
Annotation messages of failure only |
pull-request-number |
Number of associated pull request, if exists |
pull-request-url |
URL of associated pull request, if exists |
cancelled |
true if any check run is cancelled |
skipped |
true if all checks are skipped |
If the workflow run contains annotation messages, this action collects them and returns as a single string.
annotation-messagesannotation-failure-messages
If the commit of the workflow run is associated with a pull request, this action returns the following outputs:
pull-request-numberpull-request-url
GitHub Actions returns the conclusion of workflow run to failure, even if any job has been cancelled or skipped.
You can determine the conclusion using the following outputs:
cancelledindicates whether any job is cancelled.skippedindicates whether all jobs are skipped.