-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Report deployment status to Slack action (#204)
- Loading branch information
1 parent
ba6a775
commit d336bf2
Showing
2 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
.github/workflows/test-report-deployment-status-to-slack.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,38 @@ | ||
--- | ||
name: Test report-deployment-status-to-slack | ||
on: | ||
pull_request: | ||
paths: | ||
- "./report-deployment-status-to-slack" | ||
- ".github/workflows/test-report-deployment-status-to-slack.yml" | ||
|
||
jobs: | ||
test-report: | ||
name: Test Slack report | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | ||
|
||
- uses: ./report-deployment-status-to-slack | ||
with: | ||
environment: US QA Cloud | ||
tag: test-workflow | ||
slack-channel: devops-alerts | ||
failure: false | ||
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
||
test-report-failure: | ||
name: Test Slack report failure | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 | ||
|
||
- uses: ./report-deployment-status-to-slack | ||
with: | ||
project: Server | ||
environment: US QA Cloud | ||
tag: test-workflow-failure | ||
slack-channel: devops-alerts | ||
failure: true | ||
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
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,55 @@ | ||
name: "Report deployment status to Slack" | ||
inputs: | ||
project: | ||
description: "The name of the project." | ||
required: true | ||
tag: | ||
description: "The name of the branch or tag." | ||
required: true | ||
environment: | ||
description: "The name of the environment." | ||
required: true | ||
slack-channel: | ||
description: "The name of the slack channel." | ||
required: true | ||
default: team-eng-qa-devops | ||
failure: | ||
description: "If message should be a failure message" | ||
required: false | ||
default: 'false' | ||
AZURE_KV_CI_SERVICE_PRINCIPAL: | ||
description: "The service principal used to authenticate to Azure." | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Login to Azure - Prod Subscription | ||
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7 | ||
with: | ||
creds: ${{ inputs.AZURE_KV_CI_SERVICE_PRINCIPAL }} | ||
|
||
- name: Retrieve slack secrets | ||
id: retrieve-slack-secrets | ||
uses: bitwarden/gh-actions/get-keyvault-secrets@master | ||
with: | ||
keyvault: bitwarden-ci | ||
secrets: "slack-bot-token" | ||
|
||
- name: Post to a Slack channel on success | ||
if: ${{ inputs.failure == 'false' }} | ||
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 | ||
with: | ||
channel-id: ${{ inputs.slack-channel }} | ||
slack-message: ":white_check_mark: Updated ${{ inputs.environment }} to `${{ inputs.tag }}` on Server." | ||
env: | ||
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }} | ||
|
||
- name: Post to a Slack channel on failure | ||
if: ${{ inputs.failure == 'true' }} | ||
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 | ||
with: | ||
channel-id: ${{ inputs.slack-channel }} | ||
slack-message: ":x: Failed to update ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\nPlease retry or contact @devops team." | ||
env: | ||
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }} |