Skip to content

Commit

Permalink
Added an action to send notification to slack (#447)
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpitre authored Jun 5, 2024
1 parent 7825d05 commit 5adf620
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
48 changes: 48 additions & 0 deletions .github/actions/notify-slack/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Notify Slack'
description: 'Send a notification to a Slack channel with an error message'
inputs:
OP_SERVICE_ACCOUNT_TOKEN:
description: 'The service account token for 1Password'
required: true
type: string

runs:
using: 'composite'
steps:
- name: Load secrets from 1Password
id: onepw_secrets
uses: 1password/[email protected]
with:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ inputs.OP_SERVICE_ACCOUNT_TOKEN }}
CREDENTIALS: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/ifkeehu5gzi7wy5ub5qvwkaire/credential"
SLACK_WEBHOOK_URL: "op://rbiv7rvkkrsdlpcrz3bmv7nmcu/Slack webhook URLs/internal-github-action-alerts/internal-github-action-alerts"

- name: Post notification in Slack channel
uses: slackapi/[email protected]
with:
payload: |
{
"channel": "C074SPVCH6H",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": ":x: ERROR running Github action \"${{ github.workflow }}\"",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ env.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
12 changes: 12 additions & 0 deletions .github/workflows/api-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,15 @@ jobs:
API_URL: 'https://api-dev.mobilitydatabase.org'
secrets:
REFRESH_TOKEN: ${{ secrets.DEV_API_TEST_REFRESH_TOKEN }}

notify-slack-on-failure:
needs: [ api-build-deployment, integration-tests ]
if: always() && (needs.api-build-deployment.result == 'failure' || needs.integration-tests.result == 'failure')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Notify Slack
uses: ./.github/actions/notify-slack
with:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
2 changes: 1 addition & 1 deletion scripts/tunnel-kill.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
# tunnel-kill.sh
# Notice: This script will kill a process that was started with parameters "ssh -fN -L" and assumes that you didn't create any other ssh tunnel with the mentioned parameters.

ps aux | grep "[s]sh -fN -L" | awk '{print $2}' | xargs kill -9
ps aux | grep "[s]sh -o StrictHostKeyChecking=no -fN -L" | awk '{print $2}' | xargs kill -9

0 comments on commit 5adf620

Please sign in to comment.