Skip to content

Commit

Permalink
[DEVOPS-615] Added Slack notification.
Browse files Browse the repository at this point in the history
  • Loading branch information
sonnykt committed Sep 3, 2024
1 parent b3991b4 commit 1b1fed7
Showing 1 changed file with 74 additions and 2 deletions.
76 changes: 74 additions & 2 deletions .github/workflows/test-scaffold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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
-
Expand All @@ -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/[email protected]
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 }}

0 comments on commit 1b1fed7

Please sign in to comment.