Repository navigation
110 lines (102 loc) · 4.67 KB
/
Copy pathbench-verify-deploy.yml
File metadata and controls
110 lines (102 loc) · 4.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright the Vortex contributors
#
# Check bench on each production deployment of the app. The `vortex` Vercel
# project builds and deploys the app (the marketing site and bench) through its
# git integration, which records each deployment as a GitHub deployment. On
# each push to main, this waits for that commit's production deployment, then
# runs scripts/verify-web-deploy.mjs against bench's paths under /bench on that
# deployment's own URL: the build commit in /api/health, a representative
# group and chart, and the landing and chart pages. It probes the deployment's
# URL, so it checks the deployment of this commit.
#
# It runs on push, not on `deployment_status`: `on:` cannot filter that event
# by environment, so each preview deployment started a run that skipped the
# job and showed "Bench: verify production deploy" as a skipped check on every
# pull request.
#
# The CDN check (a cache HIT on a repeated landing page and chart API request)
# runs on BENCH_SITE_BASE_URL, bench.vortex.dev, because production caches only
# that form of bench's pages: their HTML differs from the /bench form's. It runs
# only once bench.vortex.dev's /api/health reports this deployment's commit,
# and is skipped, with a notice, while the domain serves another deployment or
# project.
#
# A protected deployment URL needs Vercel's Protection Bypass for Automation:
# set its secret as the repository secret VERCEL_AUTOMATION_BYPASS_SECRET.
# Without it, a protected production URL fails the check.
name: Bench Verify Deploy
on:
push:
branches: [main]
workflow_dispatch:
permissions:
contents: read
deployments: read
concurrency:
group: bench-verify-deploy-${{ github.sha }}
cancel-in-progress: false
jobs:
verify:
name: "Bench: verify production deploy"
# Only main deploys to production; a manual run on another branch would
# wait for a deployment that never comes.
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-26.04
timeout-minutes: 30
steps:
# Vercel's git integration records the production deployment of each
# push to main as a GitHub deployment in the "Production" environment
# ("Production – <project>" when a repository has several projects), and
# its success status holds the deployment's URL. A build takes a few
# minutes. The lighthouse.yml jobs wait for a commit's preview the same
# way (.github/actions/preview-proxy).
- name: Wait for the Vercel production deployment
id: deployment
timeout-minutes: 21
env:
GH_TOKEN: ${{ github.token }}
SHA: ${{ github.sha }}
# No `set -e`: a failed API call is retried on the next pass.
run: |
deployments="repos/${GITHUB_REPOSITORY}/deployments"
for _ in $(seq 1 80); do
id="$(gh api "${deployments}?sha=${SHA}" \
--jq 'map(select(.creator.login == "vercel[bot]" and (.environment | startswith("Production"))))[0].id // empty')"
if [ -n "${id}" ]; then
read -r state url < <(gh api "${deployments}/${id}/statuses" \
--jq '.[0] | "\(.state) \(.environment_url // "")"')
case "${state}" in
success)
echo "Production deployment: ${url}"
echo "url=${url}" >> "$GITHUB_OUTPUT"
exit 0 ;;
failure | error)
echo "::error::The Vercel production deployment of ${SHA} failed."
exit 1 ;;
esac
fi
sleep 15
done
echo "::error::No Vercel production deployment of ${SHA} after 20 minutes."
exit 1
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version-file: .nvmrc
- name: Verify bench on the deployment
timeout-minutes: 4
env:
DEPLOY_URL: ${{ steps.deployment.outputs.url }}
EXPECTED_SHA: ${{ github.sha }}
VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
# bench.vortex.dev, where the CDN check runs. Unset, the check is skipped.
CDN_URL: ${{ vars.BENCH_SITE_BASE_URL }}
run: |
set -Eeuo pipefail
[[ "${DEPLOY_URL}" == https://* ]] || { echo "::error::The deployment reported no HTTPS URL: '${DEPLOY_URL}'."; exit 1; }
node scripts/verify-web-deploy.mjs "${DEPLOY_URL%/}/bench" "${EXPECTED_SHA}" production "${CDN_URL%/}"