diff --git a/.github/actions/notify-slack/action.yml b/.github/actions/notify-slack/action.yml new file mode 100644 index 000000000..10fb2208c --- /dev/null +++ b/.github/actions/notify-slack/action.yml @@ -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/load-secrets-action@v2.0.0 + 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/slack-github-action@v1.26.0 + 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 diff --git a/.github/workflows/api-dev.yml b/.github/workflows/api-dev.yml index f0712190a..ceff48ce7 100644 --- a/.github/workflows/api-dev.yml +++ b/.github/workflows/api-dev.yml @@ -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 }} diff --git a/scripts/tunnel-kill.sh b/scripts/tunnel-kill.sh index aa712f18f..b7bf042cd 100755 --- a/scripts/tunnel-kill.sh +++ b/scripts/tunnel-kill.sh @@ -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