Skip to content

Commit fc8fc73

Browse files
authored
test: tag @metamask-qa-team in feature flag drift Slack noti (#289)
test: tag @metamask-qa-team in feature flag drift Slack noti (#289)
1 parent d0f155a commit fc8fc73

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

  • .github/actions/feature-flag-drift-slack-noti

.github/actions/feature-flag-drift-slack-noti/action.yml

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ inputs:
1515
description: 'URL of the sync PR (optional; included in message when provided)'
1616
required: false
1717
default: ''
18+
slack-subteam:
19+
description: 'Slack user group ID to mention. Defaults to @metamask-qa-team. Pass empty to skip the mention.'
20+
required: false
21+
default: S0832MYT8QZ # @metamask-qa-team
1822

1923
runs:
2024
using: composite
@@ -26,35 +30,53 @@ runs:
2630
TITLE: ${{ inputs.title }}
2731
WORKFLOW_URL: ${{ inputs.workflow-run-url }}
2832
PR_URL: ${{ inputs.pr-url }}
33+
SLACK_SUBTEAM: ${{ inputs.slack-subteam }}
2934
run: |
35+
# Incoming webhooks only notify a user group with <!subteam^ID>.
36+
# Mention goes at the end of the message, not in the title.
37+
# Keep it in `text` too so Slack still fires the push notification.
38+
HEADLINE="*[${TITLE}] Feature Flags Drift Detected in E2E tests vs Prod* :warning:"
39+
QA_MENTION=""
40+
if [[ -n "$SLACK_SUBTEAM" ]]; then
41+
QA_MENTION="<!subteam^${SLACK_SUBTEAM}|@metamask-qa-team>"
42+
fi
43+
3044
# Use multiple blocks instead of newlines - more reliable in Slack
3145
if [[ -n "$PR_URL" ]]; then
3246
PAYLOAD=$(jq -n \
33-
--arg title "$TITLE" \
47+
--arg headline "$HEADLINE" \
48+
--arg mention "$QA_MENTION" \
3449
--arg pr_url "$PR_URL" \
3550
--arg workflow_url "$WORKFLOW_URL" \
3651
'{
37-
text: ("*[" + $title + "] Feature Flags Drift Detected in E2E tests vs Prod* :warning:"),
38-
blocks: [
39-
{ type: "section", text: { type: "mrkdwn", text: ("*[" + $title + "] Feature Flags Drift Detected in E2E tests vs Prod* :warning:") } },
40-
{ type: "section", text: { type: "mrkdwn", text: "Check the workflow run for details: download the drift report JSON artifact and review the report." } },
41-
{ type: "section", text: { type: "mrkdwn", text: "You can run command `yarn feature-flags:sync:update` locally to update the registry." } },
42-
{ type: "section", text: { type: "mrkdwn", text: ("A sync PR has been created: <" + $pr_url + "|View PR>") } },
43-
{ type: "section", text: { type: "mrkdwn", text: ("<" + $workflow_url + "|View workflow run>") } }
44-
]
52+
text: (if $mention == "" then $headline else ($headline + " " + $mention) end),
53+
link_names: true,
54+
blocks: (
55+
[
56+
{ type: "section", text: { type: "mrkdwn", text: $headline } },
57+
{ type: "section", text: { type: "mrkdwn", text: "Check the workflow run for details: download the drift report JSON artifact and review the report." } },
58+
{ type: "section", text: { type: "mrkdwn", text: "You can run command `yarn feature-flags:sync:update` locally to update the registry." } },
59+
{ type: "section", text: { type: "mrkdwn", text: ("A sync PR has been created: <" + $pr_url + "|View PR>") } },
60+
{ type: "section", text: { type: "mrkdwn", text: ("<" + $workflow_url + "|View workflow run>") } }
61+
] + (if $mention == "" then [] else [{ type: "section", text: { type: "mrkdwn", text: $mention } }] end)
62+
)
4563
}')
4664
else
4765
PAYLOAD=$(jq -n \
48-
--arg title "$TITLE" \
66+
--arg headline "$HEADLINE" \
67+
--arg mention "$QA_MENTION" \
4968
--arg workflow_url "$WORKFLOW_URL" \
5069
'{
51-
text: ("*[" + $title + "] Feature Flags Drift Detected in E2E tests vs Prod* :warning:"),
52-
blocks: [
53-
{ type: "section", text: { type: "mrkdwn", text: ("*[" + $title + "] Feature Flags Drift Detected in E2E tests vs Prod* :warning:") } },
54-
{ type: "section", text: { type: "mrkdwn", text: "Check the workflow run for details: download the drift report JSON artifact and review the report." } },
55-
{ type: "section", text: { type: "mrkdwn", text: "You can run command `yarn feature-flags:sync:update` locally to update the registry." } },
56-
{ type: "section", text: { type: "mrkdwn", text: ("<" + $workflow_url + "|View workflow run>") } }
57-
]
70+
text: (if $mention == "" then $headline else ($headline + " " + $mention) end),
71+
link_names: true,
72+
blocks: (
73+
[
74+
{ type: "section", text: { type: "mrkdwn", text: $headline } },
75+
{ type: "section", text: { type: "mrkdwn", text: "Check the workflow run for details: download the drift report JSON artifact and review the report." } },
76+
{ type: "section", text: { type: "mrkdwn", text: "You can run command `yarn feature-flags:sync:update` locally to update the registry." } },
77+
{ type: "section", text: { type: "mrkdwn", text: ("<" + $workflow_url + "|View workflow run>") } }
78+
] + (if $mention == "" then [] else [{ type: "section", text: { type: "mrkdwn", text: $mention } }] end)
79+
)
5880
}')
5981
fi
6082
{

0 commit comments

Comments
 (0)