Skip to content

Commit

Permalink
Add slack notification to github action (#33)
Browse files Browse the repository at this point in the history
* Add slack notification to github action

* final polish and undo changes

* add same notification to weekly action
  • Loading branch information
isabelrios authored May 10, 2024
1 parent d58accb commit b97bfc4
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/production-weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,19 @@ jobs:

- name: Update DB - test coverage
run: python ./__main__.py --report-type test-case-coverage --project ALL

- name: Set job log URL
if: always()
run: echo "JOB_LOG_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
- name: Send custom JSON data to Slack workflow
if: always()
id: slack
uses: slackapi/slack-github-action@v1.26.0
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

with:
payload-file-path: "./payload-slack-content.json"
20 changes: 17 additions & 3 deletions .github/workflows/staging-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
description: 'Default branch'
required: true
default: 'master'

jobs:
deploy:
name: Update testops DB
Expand Down Expand Up @@ -47,7 +48,20 @@ jobs:
# run: python ./__main__.py --report-type test-run-counts --project fenix --start-date 2021-08-15 --end-date 2021-10-01

- name: Update DB - test coverage
run: python ./__main__.py --report-type test-case-coverage --project ALL
#run: python ./__main__.py --report-type test-case-coverage --project fenix

#run: python ./__main__.py --report-type test-case-coverage --project ALL
run: python ./__main__.py --report-type test-case-coverage --project fenix
- name: Set job log URL
if: always()
run: echo "JOB_LOG_URL=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> $GITHUB_ENV
- name: Send custom JSON data to Slack workflow
if: always()
id: slack
uses: slackapi/slack-github-action@v1.26.0
env:
JOB_STATUS: ${{ job.status == 'success' && ':white_check_mark:' || job.status == 'failure' && ':x:' }}
JOB_STATUS_COLOR: ${{ job.status == 'success' && '#36a64f' || job.status == 'failure' && '#FF0000' }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK

with:
payload-file-path: "./payload-slack-content.json"
39 changes: 39 additions & 0 deletions payload-slack-content.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"attachments": [
{
"color": "${{ env.JOB_STATUS_COLOR }}",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":looker: Looker Github Action :github: - Weekly Graphs Update",
"emoji": true
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Status: ${{ env.JOB_STATUS }}\n Logs: <${{ env.JOB_LOG_URL }}|Build Logs>"
}
},
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": ":testops-notify: created by <www.go.com|Mobile Test Engineering>"
}
]
}
]
}
]
}

0 comments on commit b97bfc4

Please sign in to comment.