Skip to content

Commit

Permalink
[DEVOPS-1733] - Add Feature Branch DB Migration Awareness (#248)
Browse files Browse the repository at this point in the history
* Add feature branch db migration awareness
  • Loading branch information
Eeebru authored Feb 14, 2024
1 parent eb7025b commit 5b6221e
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 25 deletions.
61 changes: 59 additions & 2 deletions .github/workflows/test-report-deployment-status-to-slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Test report-deployment-status-to-slack
on:
pull_request:
paths:
- "./report-deployment-status-to-slack/**"
- "report-deployment-status-to-slack/**"
- ".github/workflows/test-report-deployment-status-to-slack.yml"

jobs:
test-report-start:
name: Test Slack report failure
name: Test Slack report start
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
Expand Down Expand Up @@ -58,3 +58,60 @@ jobs:
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-db-migration:
name: Test Slack report with different DB migration scenerios
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1

- name: Slack report with DB migration true on main
uses: ./report-deployment-status-to-slack
with:
project: Server
environment: US QA Cloud
tag: main
slack-channel: devops-alerts-test
event: 'success'
commit-sha: ${{ github.sha }}
db_migration_detected: true
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Slack report with DB migration false on main
uses: ./report-deployment-status-to-slack
with:
project: Server
environment: US QA Cloud
tag: main
slack-channel: devops-alerts-test
event: 'failure'
commit-sha: ${{ github.sha }}
db_migration_detected: false
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Slack report with DB migration true on test branch
uses: ./report-deployment-status-to-slack
with:
project: Server
environment: US QA Cloud
tag: test-branch
slack-channel: devops-alerts-test
event: 'failure'
commit-sha: ${{ github.sha }}
db_migration_detected: true
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Slack report with DB migration false on test branch
uses: ./report-deployment-status-to-slack
with:
project: Server
environment: US QA Cloud
tag: test-branch
slack-channel: devops-alerts-test
event: 'success'
commit-sha: ${{ github.sha }}
db_migration_detected: false
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}
83 changes: 60 additions & 23 deletions report-deployment-status-to-slack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ inputs:
commit-sha:
description: "The SHA of the branch or tag."
required: true
db_migration_detected:
description: "Whether a database migration was detected."
required: false
default: false
environment:
description: "The name of the environment."
required: true
Expand Down Expand Up @@ -56,32 +60,65 @@ runs:
id: setup
shell: bash
run: |
case "${{ inputs.event }}" in
start)
SLACK_MESSAGE=":loading: Updating ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
if [[ ${{ inputs.db_migration_detected }} == true ]]; then
case "${{ inputs.event }}" in
start)
SLACK_MESSAGE=":loading: Updating ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
:red_siren: This branch has database migration changes."
;;
success)
SLACK_MESSAGE=":white_check_mark: Updated ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
:red_siren: This branch has database migration changes."
;;
failure)
SLACK_MESSAGE=":x: Failed to update ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
Please retry or contact @devops team.
:red_siren: This branch has database migration changes."
;;
cancelled)
SLACK_MESSAGE=":hand: Cancelled update of ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
:red_siren: This branch has database migration changes."
;;
esac
else
case "${{ inputs.event }}" in
start)
SLACK_MESSAGE=":loading: Updating ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
success)
SLACK_MESSAGE=":white_check_mark: Updated ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
success)
SLACK_MESSAGE=":white_check_mark: Updated ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
failure)
SLACK_MESSAGE=":x: Failed to update ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
Please retry or contact @devops team."
;;
failure)
SLACK_MESSAGE=":x: Failed to update ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`
Please retry or contact @devops team."
;;
cancelled)
SLACK_MESSAGE=":hand: Cancelled update of ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
esac
cancelled)
SLACK_MESSAGE=":hand: Cancelled update of ${{ inputs.environment }} to \`${{ inputs.tag }}\` on ${{ inputs.project }}.
${{ inputs.url }}
SHA: \`${{ inputs.commit-sha }}\`"
;;
esac
fi
echo 'slack_message<<EOF' >> $GITHUB_OUTPUT
echo "$SLACK_MESSAGE" >> $GITHUB_OUTPUT
Expand Down

0 comments on commit 5b6221e

Please sign in to comment.