Skip to content

Commit 894bfa4

Browse files
ci(frontend-deploy): announce a deploy when it starts (#8398)
1 parent 3fea16f commit 894bfa4

3 files changed

Lines changed: 47 additions & 10 deletions

File tree

.github/actions/notify-slack-deploy/action.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ inputs:
1515
description: The environment that was deployed to.
1616
required: false
1717
default: production
18-
conclusion:
18+
state:
1919
description: >
20-
The deploy run's conclusion, straight from workflow_run. Only success and
21-
cancelled get their own copy; anything else reads as a failure.
20+
in_progress before the deploy runs, otherwise the production job's
21+
result. Only in_progress, success and cancelled get their own copy;
22+
anything else reads as a failure.
2223
required: true
2324
commit_sha:
2425
description: The commit that was deployed.
@@ -47,7 +48,7 @@ runs:
4748
SERVICE: ${{ inputs.service }}
4849
APP_URL: ${{ inputs.app_url }}
4950
ENVIRONMENT: ${{ inputs.environment }}
50-
CONCLUSION: ${{ inputs.conclusion }}
51+
STATE: ${{ inputs.state }}
5152
COMMIT_SHA: ${{ inputs.commit_sha }}
5253
ACTOR: ${{ inputs.actor }}
5354
RUN_URL: ${{ inputs.run_url }}
@@ -77,7 +78,7 @@ runs:
7778
jq -n \
7879
--arg service "$SERVICE" \
7980
--arg environment "$ENVIRONMENT" \
80-
--arg conclusion "$CONCLUSION" \
81+
--arg state "$STATE" \
8182
--arg short_sha "${COMMIT_SHA:0:7}" \
8283
--arg actor "$ACTOR" \
8384
--arg app_url "$APP_URL" \

.github/actions/notify-slack-deploy/payload.jq

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,23 @@
33

44
($environment | (.[0:1] | ascii_upcase) + .[1:]) as $env_name |
55

6-
# Only success and cancelled need their own words. Everything else GitHub
7-
# reports, timed_out and skipped included, means the deploy did not happen.
8-
(if $conclusion == "success" then
6+
# Only in_progress, success and cancelled need their own words. Everything
7+
# else, timed_out and skipped included, means the deploy did not happen.
8+
(if $state == "in_progress" then
9+
{
10+
headline: "⏳ \($service) deploying to \($environment)",
11+
body: "Tests and deploy are running. \($env_name) is still on the previous release.",
12+
actor_label: "Pushed by",
13+
link_app: false
14+
}
15+
elif $state == "success" then
916
{
1017
headline: "🚀 \($service) deployed to \($environment)",
1118
body: "🧪 *\($env_name) smoke test required*\n\nPlease verify the application directly in \($environment).",
1219
actor_label: "Deployed by",
1320
link_app: true
1421
}
15-
elif $conclusion == "cancelled" then
22+
elif $state == "cancelled" then
1623
{
1724
headline: "⏭️ \($service) deploy to \($environment) stopped",
1825
# run-tests cancels itself in progress when the next commit lands on main,

.github/workflows/frontend-deploy-production.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,35 @@ on:
99
- .github/**
1010

1111
jobs:
12+
notify-production-deploy-started:
13+
name: Notify Production Deploy Started
14+
# No needs, so this lands within seconds of the push. Knowing a deploy is
15+
# in flight is only useful while it still is.
16+
runs-on: ubuntu-latest
17+
permissions:
18+
# Enough to resolve the local action below.
19+
contents: read
20+
21+
steps:
22+
- name: Cloning repo
23+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0
24+
with:
25+
# Nothing runs git after this, so the token need not persist.
26+
persist-credentials: false
27+
28+
- name: Notify Slack
29+
# A Slack outage must not hold up a deploy.
30+
continue-on-error: true
31+
uses: ./.github/actions/notify-slack-deploy
32+
with:
33+
webhook_url: ${{ secrets.SLACK_FRONTEND_DEPLOY_WEBHOOK }}
34+
service: Frontend
35+
app_url: https://app.flagsmith.com
36+
state: in_progress
37+
commit_sha: ${{ github.sha }}
38+
actor: ${{ github.actor }}
39+
run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
40+
1241
run-unit-tests:
1342
runs-on: ubuntu-latest
1443
name: Run Unit Tests
@@ -136,7 +165,7 @@ jobs:
136165
webhook_url: ${{ secrets.SLACK_FRONTEND_DEPLOY_WEBHOOK }}
137166
service: Frontend
138167
app_url: https://app.flagsmith.com
139-
conclusion: ${{ steps.outcome.outputs.conclusion }}
168+
state: ${{ steps.outcome.outputs.conclusion }}
140169
commit_sha: ${{ github.sha }}
141170
actor: ${{ github.actor }}
142171
run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 commit comments

Comments
 (0)