Skip to content

Commit e007653

Browse files
committed
ci: simplify preview alias derivation
Use `git rev-parse --short=8 HEAD` for the preview alias in deploy:preview, and dedupe the CI side: the meta step now emits a single `sha` output and the alias is built inline as `preview-<sha>`, dropping the duplicate alias output and env var. Assisted-by: ClaudeCode:claude-opus-4-8
1 parent 337b584 commit e007653

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,28 @@ jobs:
5151
- id: meta
5252
env:
5353
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
54-
run: |
55-
echo "sha=${HEAD_SHA:0:8}" >> "$GITHUB_OUTPUT"
56-
echo "alias=preview-${HEAD_SHA:0:8}" >> "$GITHUB_OUTPUT"
54+
run: echo "sha=${HEAD_SHA:0:8}" >> "$GITHUB_OUTPUT"
5755
# Upload a new Worker version without promoting it to production. The
58-
# --preview-alias mints a stable URL (<sha>-audiotrail.<subdomain>.workers.dev).
56+
# --preview-alias mints a stable URL (preview-<sha>-audiotrail.<subdomain>.workers.dev).
5957
- id: preview
6058
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
6159
with:
6260
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
6361
packageManager: pnpm
64-
command: versions upload --preview-alias ${{ steps.meta.outputs.alias }}
62+
command: versions upload --preview-alias preview-${{ steps.meta.outputs.sha }}
6563
- uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
6664
env:
6765
PREVIEW_URL: ${{ steps.preview.outputs.deployment-url }}
68-
ALIAS: ${{ steps.meta.outputs.alias }}
6966
SHA: ${{ steps.meta.outputs.sha }}
7067
with:
7168
script: |
7269
const marker = '<!-- audiotrail-preview -->';
7370
// wrangler-action returns the per-version URL (https://<8-hex>-<worker>.<sub>.workers.dev);
7471
// swap the version prefix for our commit alias to get the URL deploy:preview reproduces.
75-
const versionUrl = process.env.PREVIEW_URL;
76-
const alias = process.env.ALIAS;
7772
const sha = process.env.SHA;
78-
const aliasUrl = versionUrl && alias
79-
? versionUrl.replace(/^https:\/\/[0-9a-f]{8}-/, `https://${alias}-`)
73+
const versionUrl = process.env.PREVIEW_URL;
74+
const aliasUrl = versionUrl
75+
? versionUrl.replace(/^https:\/\/[0-9a-f]{8}-/, `https://preview-${sha}-`)
8076
: '';
8177
const body = [
8278
marker,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "oxlint && oxfmt --check && vue-tsc",
1414
"lint:fix": "oxlint --fix && oxfmt --write",
1515
"deploy": "pnpm build && wrangler deploy",
16-
"deploy:preview": "pnpm build && wrangler versions upload --preview-alias preview-$(git rev-parse HEAD | head -c 8)"
16+
"deploy:preview": "pnpm build && wrangler versions upload --preview-alias preview-$(git rev-parse --short=8 HEAD)"
1717
},
1818
"dependencies": {
1919
"@fontsource-variable/fraunces": "^5.2.9",

0 commit comments

Comments
 (0)