Skip to content

Commit

Permalink
Publish slack message to slack channel (#20)
Browse files Browse the repository at this point in the history
* add actions to publish slack messages
  • Loading branch information
benlee0423 authored Aug 14, 2023
1 parent e0b8530 commit ff42676
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 28 deletions.
29 changes: 29 additions & 0 deletions .github/action_templates/slack/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Send Slack Message
description: "Send slack message to a channel"

inputs:
slack-webhook-url:
description: 'Slack webhook url'
required: true
job-status:
description: 'Job status'
required: true
pull_request_url:
description: 'Pull request url'
required: true
head_commit_url:
description: 'Head commit url'
required: true

runs:
using: "composite"
steps:
- name: send slack message
uses: slackapi/slack-github-action@v1.24.0
with:
payload: |
{
"text": "GitHub Action build result: ${{ inputs.job-status }}\n${{ inputs.pull_request_url || inputs.head_commit_url }}"
}
env:
SLACK_WEBHOOK_URL: ${{ inputs.slack-webhook-url}}
2 changes: 1 addition & 1 deletion .github/workflows/docker_deps_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
docker-auth-token: ${{ secrets.DOCKER_AUTH_TOKEN }}
github-sha: ${{ github.sha }}
image-name: "ngen-deps"
dockerfile-name: "Dockerfile.ngen-deps"
dockerfile-name: "Dockerfile.ngen-deps"
16 changes: 16 additions & 0 deletions .github/workflows/docker_image_main_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,24 @@ jobs:
github-sha: ${{ github.sha }}
image-name: "ciroh-ngen-image"
dockerfile-name: "Dockerfile"
- name: Publish slack message
if: always()
uses: ./.github/action_templates/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
job-status: ${{ job.status }}
pull_request_url: ${{ github.event.pull_request.html_url }}
head_commit_url: ${{ github.event.head_commit.url }}
on-failure:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
- name: Publish slack message
if: always()
uses: ./.github/action_templates/slack
with:
slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL }}
job-status: ${{ job.status }}
pull_request_url: ${{ github.event.pull_request.html_url }}
head_commit_url: ${{ github.event.head_commit.url }}
2 changes: 1 addition & 1 deletion .github/workflows/docker_ngen_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
- run: echo 'The triggering workflow failed'
25 changes: 0 additions & 25 deletions .github/workflows/docker_slack.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docker_troute_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
runs-on: self-hosted
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'
- run: echo 'The triggering workflow failed'

0 comments on commit ff42676

Please sign in to comment.