From 1b1fed77a146b947aeb5262c37d9f2f9cc093845 Mon Sep 17 00:00:00 2001 From: Sonny Kieu Date: Tue, 3 Sep 2024 16:49:49 +1000 Subject: [PATCH] [DEVOPS-615] Added Slack notification. --- .github/workflows/test-scaffold.yml | 76 ++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-scaffold.yml b/.github/workflows/test-scaffold.yml index b1546ff..4dd1bf4 100644 --- a/.github/workflows/test-scaffold.yml +++ b/.github/workflows/test-scaffold.yml @@ -37,7 +37,7 @@ jobs: fail-fast: false container: - image: drevops/ci-runner:24.1.0 + image: drevops/ci-runner:24.8.0 env: CI: 1 # Prevent GitHub overriding the Docker config. @@ -68,6 +68,10 @@ jobs: DREVOPS_DEPLOY_ARTIFACT_REPORT_FILE: /tmp/artifacts/deployment_report.txt steps: + - + name: Fail + run: exit 1 + - name: Checkout the repo uses: actions/checkout@main @@ -87,7 +91,7 @@ jobs: - name: Process codebase to run in CI run: | - find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {} && sed -i -e 's#- .:/app:delegated##' {}" + find . -name "docker-compose.yml" -print0 | xargs -0 -I {} sh -c "sed -i -e ''/###/d'' {} && sed -i -e ''s/##//'' {} && sed -i -e 's#- .:/app:delegated#[]#' {}" mkdir -p /tmp/workspace/code - @@ -105,3 +109,71 @@ jobs: name: Install GovCMS profile run: ahoy install + notify: + runs-on: ubuntu-latest + needs: [ test ] + if: ${{ !cancelled() }} + steps: + - + name: Notify failures to Slack + id: failure_slack + if: ${{ contains(needs.*.result, 'failure') }} + uses: slackapi/slack-github-action@v1.27.0 + with: + # See https://github.com/slackapi/slack-github-action?tab=readme-ov-file + channel-id: ${{ vars.SLACK_CHANNEL }} + payload: | + { + "attachments": [ + { + "color": "#ff0000", + "blocks": [ + { + "type": "header", + "text": { + "type": "plain_text", + "text": "Scaffold test failure" + } + }, + { + "type": "context", + "elements": [ + { + "type": "mrkdwn", + "text": "Some jobs were not successful, please view the pipeline and rerun." + } + ] + }, + { + "type": "section", + "fields": [ + { + "type": "mrkdwn", + "text": "*Project Type:*\${{ matrix.project_type }}" + }, + { + "type": "mrkdwn", + "text": "*GovCMS Image:*\n${{ matrix.govcms_image }}" + } + ] + }, + { + "type": "actions", + "block_id": "view_pipeline", + "elements": [ + { + "type": "button", + "text": { + "type": "plain_text", + "text": "View pipeline" + }, + "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs" + } + ] + } + ] + } + ] + } + env: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}