-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(slackbot): clean up slack alerts (#1272)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> - Seems to be a classic case of "smør på flesk" to have both the pipeline failing slack message and the k6-tests slack message. Won't give any additional value until we can upload the test result file in the message and make it sweeter: slackapi/slack-github-action#92 Removing for now. - Tweaked the template a bit for the pipeline slack message - This is a good start, and we can expand by adding more info on the slack-message, for now posting a status for each workflow. <img width="673" alt="image" src="https://github.com/user-attachments/assets/d2dccb8c-2e1f-44da-add1-dd8a0a9af2f7"> ## Related Issue(s) - #230 ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Enhanced Slack notifications for pipeline statuses with improved structure and clarity. - Introduced a new GitHub Actions workflow for sending CI/CD status updates to Slack, capturing results from multiple jobs. - Updated existing Slack message jobs to report on both success and failure conditions across various environments. - **Bug Fixes** - Removed unnecessary Slack message sending on K6 test failures, streamlining the workflow. - **Documentation** - Updated environment variables and job conditions for better clarity and functionality in CI/CD processes. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
- Loading branch information
Showing
7 changed files
with
174 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,54 @@ | ||
{ | ||
"blocks": [ | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*:rotating_light: Pipeline failing for *${{ env.ENVIRONMENT }}* :rotating_light:*\n\nPlease check the workflow for more details." | ||
} | ||
}, | ||
{ "type": "divider" }, | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View Run" | ||
}, | ||
"url": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||
"attachments": [ | ||
{ | ||
"color": "#FF0000", | ||
"blocks": [ | ||
{ | ||
"type": "header", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "Github pipeline status", | ||
"emoji": true | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Environment:* ${{ env.ENVIRONMENT }}" | ||
} | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "*Job Status:*\n• Infrastructure: ${{ env.INFRA_STATUS }}\n• Apps: ${{ env.APPS_STATUS }}\n• Slack Notifier: ${{ env.SLACK_NOTIFIER_STATUS }}\n• E2E Tests: ${{ env.E2E_TESTS_STATUS }}\n• Schema NPM: ${{ env.SCHEMA_NPM_STATUS }}\n• Publish: ${{ env.PUBLISH_STATUS }}" | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "section", | ||
"text": { | ||
"type": "mrkdwn", | ||
"text": "Please check the workflow for more details." | ||
} | ||
}, | ||
{ | ||
"type": "divider" | ||
}, | ||
{ | ||
"type": "actions", | ||
"elements": [ | ||
{ | ||
"type": "button", | ||
"text": { | ||
"type": "plain_text", | ||
"text": "View Run" | ||
}, | ||
"url": "${{ env.RUN_URL }}" | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
.github/workflows/action-send-ci-cd-status-slack-message.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
name: Send CI/CD Status Slack Message | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
required: true | ||
type: string | ||
infra_status: | ||
type: string | ||
description: "Status of the infrastructure deployment job" | ||
default: "skipped" | ||
apps_status: | ||
type: string | ||
description: "Status of the apps deployment job" | ||
default: "skipped" | ||
slack_notifier_status: | ||
type: string | ||
description: "Status of the Slack notifier deployment job" | ||
default: "skipped" | ||
e2e_tests_status: | ||
type: string | ||
description: "Status of the end-to-end tests job" | ||
default: "skipped" | ||
schema_npm_status: | ||
type: string | ||
description: "Status of the schema npm publishing job" | ||
default: "skipped" | ||
publish_status: | ||
type: string | ||
description: "Status of the docker image publishing job" | ||
default: "skipped" | ||
secrets: | ||
SLACK_BOT_TOKEN: | ||
required: true | ||
SLACK_CHANNEL_ID: | ||
required: true | ||
|
||
jobs: | ||
send-slack-message: | ||
name: Send Slack message | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Determine status emojis | ||
id: status-emojis | ||
run: | | ||
determine_emoji() { | ||
local -A emoji_map=( | ||
[success]=":white_check_mark:" | ||
[failure]=":x:" | ||
[cancelled]=":warning:" | ||
[skipped]=":ballot_box_with_check:" | ||
) | ||
echo "${emoji_map[$1]:-Invalid status: $1}" | ||
} | ||
{ | ||
echo "INFRA_EMOJI=$(determine_emoji "${{ inputs.infra_status }}")" | ||
echo "APPS_EMOJI=$(determine_emoji "${{ inputs.apps_status }}")" | ||
echo "SLACK_NOTIFIER_EMOJI=$(determine_emoji "${{ inputs.slack_notifier_status }}")" | ||
echo "E2E_TESTS_EMOJI=$(determine_emoji "${{ inputs.e2e_tests_status }}")" | ||
echo "SCHEMA_NPM_EMOJI=$(determine_emoji "${{ inputs.schema_npm_status }}")" | ||
echo "PUBLISH_EMOJI=$(determine_emoji "${{ inputs.publish_status }}")" | ||
} >> "$GITHUB_OUTPUT" | ||
- name: Send GitHub slack message | ||
id: slack | ||
env: | ||
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | ||
ENVIRONMENT: ${{ inputs.environment }} | ||
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} | ||
# statuses | ||
INFRA_STATUS: "${{ steps.status-emojis.outputs.INFRA_EMOJI }}" | ||
APPS_STATUS: "${{ steps.status-emojis.outputs.APPS_EMOJI }}" | ||
SLACK_NOTIFIER_STATUS: "${{ steps.status-emojis.outputs.SLACK_NOTIFIER_EMOJI }}" | ||
E2E_TESTS_STATUS: "${{ steps.status-emojis.outputs.E2E_TESTS_EMOJI }}" | ||
SCHEMA_NPM_STATUS: "${{ steps.status-emojis.outputs.SCHEMA_NPM_EMOJI }}" | ||
PUBLISH_STATUS: "${{ steps.status-emojis.outputs.PUBLISH_EMOJI }}" | ||
uses: slackapi/slack-github-action@v1.27.0 | ||
with: | ||
channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | ||
payload-file-path: "./.github/slack-templates/pipeline-failed.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters