Skip to content

Commit

Permalink
BRE-265-slack-commit-link (#340)
Browse files Browse the repository at this point in the history
* [BRE-265] Updating slack tag and commit hash to links

* [BRE-265] Updating slack tag and commit hash to links

* [BRE-265] Updating slack tag and commit hash to links

* [BRE-265] Updating slack tag and commit hash to links

* [BRE-265] Updating slack tag and commit hash to links (Updating test)

* [BRE-265] Updating slack tag and commit hash to links (Updating test)
  • Loading branch information
pixman20 authored Nov 5, 2024
1 parent 2759b6e commit 638a3ea
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
36 changes: 20 additions & 16 deletions .github/workflows/test-report-deployment-status-to-slack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
- "report-deployment-status-to-slack/**"
- ".github/workflows/test-report-deployment-status-to-slack.yml"

env:
TEST_REPORT_PROJECT: Server
TEST_REPORT_COMMIT_SHA: "50f7fa03dbc0f18a641206ab1a92fb11a1131572" # Use a valid commit in Server (TEST_REPORT_PROJECT) to validate the links

jobs:
test-report-start:
name: Test Slack report
Expand All @@ -15,48 +19,48 @@ jobs:
- name: Start
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: EU-QA Cloud
slack-channel: bre-alerts-test
tag: test-workflow-start
event: 'start'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_SHA
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Success
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: US-QA Cloud
slack-channel: bre-alerts-test
tag: test-workflow-success
event: 'success'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_SHA
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: Failure
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: US-QA Cloud
slack-channel: bre-alerts-test
tag: test-workflow-failure
event: 'failure'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_SHA
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

- name: No Changes
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: EU-QA Cloud
slack-channel: bre-alerts-test
tag: test-workflow-failure
event: 'no-changes'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_SHA
url: https://github.com/bitwarden/gh-actions/actions/runs/${{ github.run_id }}
AZURE_KV_CI_SERVICE_PRINCIPAL: ${{ secrets.AZURE_KV_CI_SERVICE_PRINCIPAL }}

Expand All @@ -69,51 +73,51 @@ jobs:
- name: With DB migration true on main
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: EU-QA Cloud
slack-channel: bre-alerts-test
tag: main
event: 'success'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_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: With DB migration false on main
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: US-QA Cloud
slack-channel: bre-alerts-test
tag: main
event: 'failure'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_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: With DB migration true on test branch
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: EU-QA Cloud
slack-channel: bre-alerts-test
tag: test-branch-failure
event: 'failure'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_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: With DB migration false on test branch
uses: ./report-deployment-status-to-slack
with:
project: Server
project: $TEST_REPORT_PROJECT
environment: US-QA Cloud
slack-channel: bre-alerts-test
tag: test-branch-success
event: 'success'
commit-sha: ${{ github.sha }}
commit-sha: $TEST_REPORT_COMMIT_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 }}
37 changes: 26 additions & 11 deletions report-deployment-status-to-slack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ inputs:
project:
description: "The name of the project."
required: true
project_owner:
description: "The owner/org of the project"
required: false
default: bitwarden
tag:
description: "The name of the branch or tag."
required: true
Expand All @@ -27,7 +31,7 @@ inputs:
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."
description: "URL of the deployment action run"
required: false
default: ${{ github.event.deployment_status.target_url }}
AZURE_KV_CI_SERVICE_PRINCIPAL:
Expand Down Expand Up @@ -65,39 +69,50 @@ runs:
local environment="${{ inputs.environment }}"
local tag="${{ inputs.tag }}"
local project="${{ inputs.project }}"
local project_owner="${{ inputs.project_owner }}"
local url="${{ inputs.url }}"
local commit_sha="${{ inputs.commit-sha }}"
# This action can be called from other repositories with external refs/shas, so use the passed in project rather than github.repository
local repository_url="${{ github.server_url }}/$project_owner/$project"
local commit_url="$repository_url/commit/$commit_sha"
local tag_url="$repository_url/tree/$tag"
# Slack link format: https://api.slack.com/reference/surfaces/formatting
local commit_link="<$commit_url|$commit_sha>"
local tag_link="<$tag_url|$tag>"
case $event in
start)
SLACK_MESSAGE=":loading: Deploying \`$tag\` to $environment on $project.
SLACK_MESSAGE=":loading: Deploying $tag_link to $environment on $project.
$url
SHA: \`$commit_sha\`"
SHA: $commit_link"
;;
success)
SLACK_MESSAGE=":white_check_mark: Deployed \`$tag\` to $environment on $project.
SLACK_MESSAGE=":white_check_mark: Deployed $tag_link to $environment on $project.
$url
SHA: \`$commit_sha\`"
SHA: $commit_link"
;;
failure)
SLACK_MESSAGE=":x: Failed to deploy \`$tag\` to $environment on $project.
SLACK_MESSAGE=":x: Failed to deploy $tag_link to $environment on $project.
$url
SHA: \`$commit_sha\`
SHA: $commit_link
Please retry. If the issue persists, share this message in the #team-eng-bre channel for support."
;;
cancelled)
SLACK_MESSAGE=":hand: Cancelled deploy of \`$tag\` to $environment on $project.
SLACK_MESSAGE=":hand: Cancelled deploy of $tag_link to $environment on $project.
$url
SHA: \`$commit_sha\`"
SHA: $commit_link"
;;
no-changes)
SLACK_MESSAGE=":heavy_minus_sign: No changes were made for \`$tag\` deployment to $environment on $project.
SLACK_MESSAGE=":heavy_minus_sign: No changes were made for $tag_link deployment to $environment on $project.
$url
SHA: \`$commit_sha\`"
SHA: $commit_link"
;;
esac
}
Expand Down

0 comments on commit 638a3ea

Please sign in to comment.