Skip to content

Commit

Permalink
[DEVOPS-1651] Update the QA deployment alert at the start (#215)
Browse files Browse the repository at this point in the history
* Change input and add start message

* Change test workflow

* Simplify action

* Fix

* Fix

* Fix

* Fix

* Fix

* Fix

* Change to markdown

* Fix

* CHange styling

* Change channel for tests
  • Loading branch information
michalchecinski authored Nov 29, 2023
1 parent 9c27460 commit 4b5492c
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 13 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/test-report-deployment-status-to-slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ on:
- ".github/workflows/test-report-deployment-status-to-slack.yml"

jobs:
test-report-start:
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-start
slack-channel: devops-alerts-test
event: 'start'
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

test-report:
name: Test Slack report
runs-on: ubuntu-22.04
Expand All @@ -15,10 +31,12 @@ jobs:

- uses: ./report-deployment-status-to-slack
with:
project: Server
environment: US QA Cloud
tag: test-workflow
slack-channel: devops-alerts
failure: false
tag: test-workflow-success
slack-channel: devops-alerts-test
event: 'success'
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

test-report-failure:
Expand All @@ -32,7 +50,8 @@ jobs:
project: Server
environment: US QA Cloud
tag: test-workflow-failure
slack-channel: devops-alerts
failure: true
slack-channel: devops-alerts-test
event: 'failure'
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

28 changes: 20 additions & 8 deletions report-deployment-status-to-slack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ inputs:
description: "The name of the slack channel."
required: true
default: team-eng-qa-devops
failure:
description: "If message should be a failure message"
event:
description: "Deployment event type. Possible values are start, success, or failure."
required: true
url:
description: "Deployment event type. Possible values are start, success, or failure."
required: false
default: 'false'
default: ${{ github.event.deployment_status.target_url }}
AZURE_KV_CI_SERVICE_PRINCIPAL:
description: "The service principal used to authenticate to Azure."
required: true
Expand All @@ -25,7 +28,7 @@ runs:
using: "composite"
steps:
- name: Login to Azure - Prod Subscription
uses: Azure/login@4c88f01b0e3a5600e08a37889921afd060f75cf0 # v1.5.0
uses: Azure/login@92a5484dfaf04ca78a94597f4f19fea633851fa2 # v1.4.7
with:
creds: ${{ inputs.AZURE_KV_CI_SERVICE_PRINCIPAL }}

Expand All @@ -36,20 +39,29 @@ runs:
keyvault: bitwarden-ci
secrets: "slack-bot-token"

- name: Post to a Slack channel on start
if: ${{ inputs.event == 'start' }}
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0
with:
channel-id: ${{ inputs.slack-channel }}
slack-message: ":loading: Updating ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}."
env:
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }}

- name: Post to a Slack channel on success
if: ${{ inputs.failure == 'false' }}
if: ${{ inputs.event == 'success' }}
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 ${{ inputs.project }}."
slack-message: ":white_check_mark: Updated ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}."
env:
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }}

- name: Post to a Slack channel on failure
if: ${{ inputs.failure == 'true' }}
if: ${{ inputs.event == 'failure' }}
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."
slack-message: ":x: Failed to update ${{ inputs.environment }} to `${{ inputs.tag }}` on ${{ inputs.project }}.\n ${{ inputs.url }}.\nPlease retry or contact @devops team."
env:
SLACK_BOT_TOKEN: ${{ steps.retrieve-slack-secrets.outputs.slack-bot-token }}

0 comments on commit 4b5492c

Please sign in to comment.