Skip to content

Commit

Permalink
move to reuseable action
Browse files Browse the repository at this point in the history
  • Loading branch information
MSevey committed Jul 18, 2023
1 parent 9e0724d commit 88871e9
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 14 deletions.
23 changes: 23 additions & 0 deletions .github/actions/notify-slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Define action name, description, and inputs
name: "Notify Slack"
description: "Notify Slack on Workflow Failures"

# Define action steps
runs:
using: "composite"
steps:
# run this action to get the workflow conclusion
# You can get the conclusion via env (env.WORKFLOW_CONCLUSION)
- uses: technote-space/workflow-conclusion-action@v3

- name: Notify Slack On Failure
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ env.WORKFLOW_CONCLUSION }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_RELEASE_CHANNEL }}
39 changes: 25 additions & 14 deletions .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,35 @@ jobs:
# docker_repository: <update>
# semver_version: ${{ needs.release.outputs.new_version }}

# notify-slack-on-failure will send a message to slack if the workflow fails.
# This shows how to use the reusable action. Below is how to call it directly.
notify-slack-on-failure:
needs: [yamllint, markdown-lint]
if: always()
# if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
runs-on: ubuntu-latest
steps:
# run this action to get the workflow conclusion
# You can get the conclusion via env (env.WORKFLOW_CONCLUSION)
- uses: technote-space/workflow-conclusion-action@v3
- uses: ./.github/actions/notify-slack

- name: Notify Slack On Failure
uses: ravsamhq/notify-slack-action@v2
with:
status: ${{ env.WORKFLOW_CONCLUSION }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_RELEASE_CHANNEL }}
# Option for directly calling the workflow
# notify-slack-on-failure:
# needs: [yamllint, markdown-lint]
# if: always()
# # if: always() && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
# runs-on: ubuntu-latest
# steps:
# # run this action to get the workflow conclusion
# # You can get the conclusion via env (env.WORKFLOW_CONCLUSION)
# - uses: technote-space/workflow-conclusion-action@v3

# - name: Notify Slack On Failure
# uses: ravsamhq/notify-slack-action@v2
# with:
# status: ${{ env.WORKFLOW_CONCLUSION }}
# token: ${{ secrets.GITHUB_TOKEN }}
# notification_title: "{workflow} has {status_message}"
# message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
# footer: ""
# notify_when: "failure"
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_RELEASE_CHANNEL }}

0 comments on commit 88871e9

Please sign in to comment.