From fd1db4cc12938550c1e204408a450356d135b048 Mon Sep 17 00:00:00 2001 From: Johan Blomgren Date: Fri, 29 Nov 2024 16:25:11 +0100 Subject: [PATCH] Poster feil til slack vid github action failures --- .github/workflows/backup.yml | 10 +++++++++- .github/workflows/build_and_deploy.yml | 9 ++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/backup.yml b/.github/workflows/backup.yml index 9c37d9d..a923cb7 100644 --- a/.github/workflows/backup.yml +++ b/.github/workflows/backup.yml @@ -4,6 +4,7 @@ on: schedule: # Runs at 04:00 UTC on the 1st and 17th of every month - cron: "0 4 1,15 * *" + jobs: backup-production-dataset: runs-on: ubuntu-20.04 @@ -42,4 +43,11 @@ jobs: name: Backup production dataset ${{ env.BACKUP_FILENAME }} path: backups/${{ env.BACKUP_FILENAME }} # Fails the workflow if no files are found; defaults to 'warn' - if-no-files-found: error \ No newline at end of file + if-no-files-found: error + + - name: Post build failures to Slack + if: failure() + run: | + curl -X POST --data "{\"text\": \"Backup av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/.github/workflows/build_and_deploy.yml b/.github/workflows/build_and_deploy.yml index ab6d948..981b25b 100644 --- a/.github/workflows/build_and_deploy.yml +++ b/.github/workflows/build_and_deploy.yml @@ -26,4 +26,11 @@ jobs: - name: Deploy sanity env: SANITY_AUTH_TOKEN: ${{ secrets.SANITY_DEPLOY_TOKEN }} - run: sanity deploy \ No newline at end of file + run: sanity deploy + + - name: Post build failures to Slack + if: failure() + run: | + curl -X POST --data "{\"text\": \"Deploy av $GITHUB_REPOSITORY feilet - $GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID\"}" $WEBHOOK_URL + env: + WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file