Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/send_slack_notification.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Send Slack Notification

on:
workflow_dispatch:
push:
branches:
- release/**/*

permissions:
id-token: write

jobs:
send_notification:
name: Send Slack Notification
runs-on: ubuntu-24.04
# Only run on pushes that carry new commits (or a manual dispatch);
# skip bare branch-creation pushes that have no commits
if: ${{ github.event_name != 'push' || github.event.head_commit != null }}
steps:
- name: Log in to Azure
uses: bitwarden/gh-actions/azure-login@main
with:
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
client_id: ${{ secrets.AZURE_CLIENT_ID }}

- name: Retrieve Slack secrets
id: retrieve-slack-secrets
uses: bitwarden/gh-actions/get-keyvault-secrets@main
with:
keyvault: gh-android
secrets: "SLACK-WEBHOOK-TEAM-ENG-MOBILE"

- name: Log out from Azure
uses: bitwarden/gh-actions/azure-logout@main

- name: Build message
id: msg
env:
COMMIT_URL: ${{ github.event.head_commit.url }}
COMMIT_SHA: ${{ github.event.head_commit.id }}
run: |
echo "text=:cherry-pick: <${COMMIT_URL}|${COMMIT_SHA}> into *${GITHUB_REF_NAME}*\ncc <!subteam^S022CDR7W2Z> <@U06538MSPJP>" >> "$GITHUB_OUTPUT"

- name: Send slack notification
uses: slackapi/slack-github-action@af78098f536edbc4de71162a307590698245be95 # v3.0.1
with:
webhook: ${{ steps.retrieve-slack-secrets.outputs.SLACK-WEBHOOK-TEAM-ENG-MOBILE }}
webhook-type: incoming-webhook
payload: |
text: "${{ steps.msg.outputs.text }}"
Comment on lines +37 to +51

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ QUESTION: On workflow_dispatch, github.event.head_commit is null, so this sends a malformed message to QA.

Details

The if condition on line 18 (github.event_name != 'push' || ...) intentionally lets manual dispatch runs through. But on a workflow_dispatch event, github.event.head_commit is null, so COMMIT_URL and COMMIT_SHA resolve to empty strings. The resulting Slack message becomes:

:cherry-pick: <|>  into *<branch>*
cc <!subteam^S022CDR7W2Z> <@U06538MSPJP>

i.e. an empty link <|> and no commit reference, which still pings @group-qa.

Is workflow_dispatch intended only for testing? If so, consider gating the message-build/send behind a push event, or populating the commit fields from github.sha as a fallback so a manual run doesn't ping QA with an empty commit link.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for testing and will be removed later

Loading