A GitHub Action for sending notifications as Slack Attachments

- name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: started
Configure this action via environmental variables:
TOKEN: Slack TokenCHANNEL: Slack ChannelSTATUS: defines a color of an attachment and text under Status field. Choose one of the following:
running/started/building/initializing: Yellow :yellow_square:deploying/uploading/publishing/creating: Orange :orange_square:finished/succeeded/passed/built/released: Green :green_square:failed/aborted/canceled/terminated: Red :red_square:TIMESTAMP: update previously sent message by providing an output of a previous stepATTACHMENTS_FILE: provide a path to JSON file containing a valid Slack Attachment to override a message template with your own (STATUS and SEPARATOR will be ignored)SEPARATOR: argument separator for additional fields (default ==)TIMESTAMP_FILE: a path to a file (directory and file will be created if not exist) which will contain a timestamp. Used as a buffer on complex flows that constantly update the same message (If used in multi-job workflow, you will have to collect that file as an artifact and extract it in another job)FAIL: failure trap which will tweak the message to be failed on value "true". Useful in a mid flow notification with parameter: FAIL: "${{ failure() }}" (enables to send a finished or failed message in a single step)You may add additional fields to a default message template via arguments
== may be changed by setting an environmental variable SEPARATOR with a custom value\n" if they contain whitespace - name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: finished
with:
args: |
"Download URL"==<https://my-website.com/file.exe|file>
Version==v3.1.0
Create a JSON file with Slack attachments and provide a path as an environmental variable. For instance:
curl or wget - name: Notify Slack
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
ATTACHMENTS_FILE: attachments.json
{}) or a list of attachments ([]) in a single JSON fileid field to a first notification in a workflowoutputs.timestamp of previously set id as a TIMESTAMP env.var in the next notification
id's :wink: - name: Notify
id: notify
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
START: building
- name: Update Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: released
TIMESTAMP: ${{steps.notify.outputs.timestamp}}
with:
args: |
Download==<https://my-website.com/file.exe|file>
Version==v3.1.0
id to your first notification in a workflowoutputs.timestamp of previously set id as a TIMESTAMP env.var in the next notification
id's :wink:jobs:
ci:
name: build
runs-on: ubuntu-latest
steps:
- name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: started
TIMESTAMP_FILE: .github/notify.ts
- name: Checkout
uses: actions/checkout@v2
- name: Build
run: docker build --tag=org/proj:tag .
- name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: publishing
TIMESTAMP_FILE: .github/notify.ts
- name: Push
run: docker push org/proj:tag
- uses: actions/upload-artifact@v2
with:
name: timestamp
path: .github/notify.ts
- name: Notification
if: ${{ failure() }}
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: failed
TIMESTAMP_FILE: .github/notify.ts
cd:
name: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
name: timestamp
path: .github/notify.ts
- name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: deploying
TIMESTAMP_FILE: .github/notify.ts
- name: Deploy
run: helm upgrade --install application repository/application
- name: Notification
uses: docker://reasonsoftware/action-notify-slack:v1
env:
TOKEN: ${{ secrets.SLACK_TOKEN }}
CHANNEL: ${{ secrets.SLACK_CHANNEL }}
STATUS: finished
FAIL: ${{ failure() }}
TIMESTAMP_FILE: .github/notify.ts
latest / v1 / v1.2 / v1.2.3 allowing to lock against a certain version
It's recommended to lock against a major version, for example v1uses: docker://reasonsoftware/action-notify-slack:v1 to uses: docker://docker.pkg.github.com/reasonsoftware/action-notify-slack/action-notify-slack:v1Content type
Image
Digest
Size
2.1 MB
Last updated
about 5 years ago
docker pull reasonsoftware/action-notify-slack