Github action to send notifications via slack with different templates.
This action call the action act10ns/[email protected].
Create a Slack Webhook URL using either the Incoming Webhooks App (preferred) or by attaching an incoming webhook to an existing Slack App (beware, channel override not possible when using a Slack App):
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Pass the name of the to use, available templates:
- pr
- push
- release
with:
template: push
The status
must be defined. It can either be the current job status using:
with:
status: ${{ job.status }}
or a hardcoded custom status such as "starting" or "in progress":
with:
status: in progress
Only required if the SLACK_WEBHOOK_URL
environment variable is not set.
with:
slack_webhook_url: ${{ secrets.SLACK_WEBHOOK_URL }}
The individual status of job steps can be included in the Slack message using:
with:
steps: ${{ steps }}
Note: Only steps that have a "step id" will be reported on. See example below.
To override the channel or to send the Slack message to an individual use:
with:
channel: '#workflows'
Logo displayed in slack message.
with:
logo_url: 'https://s3-us-west-2.amazonaws.com/slack-files2/bot_icons/2023-01-09/4618522117268_48.png'
The pr
template require 2 environment variables (env
) PR_URL
AND PR_NUMBER
.
The action pull-request@v2 create an new PR and output the url and number.
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: create-pr
id: pr
uses: repo-sync/pull-request@v2
with:
destination_branch: testing
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: slack - GitHub Actions Slack integration
uses: steplix/[email protected]
with:
template: pr
channel: '#back-test-pipes'
status: ${{ job.status }}
steps: ${{ toJson(steps) }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
PR_URL: ${{ steps.pr.outputs.pr_url }}
PR_NUMBER: ${{ steps.pr.outputs.pr_number }}
The release
template require NEW_TAG
environment variables (env
).
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: slack - GitHub Actions Slack integration
uses: steplix/[email protected]
with:
template: release
channel: '#back-test-pipes'
status: ${{ job.status }}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
NEW_TAG: '1.0.1'