Skip to content

Commit 68cdd27

Browse files
winsmithclaude
andcommitted
Publish pull request builds as beta bundles on the CDN
Every pull request now uploads its bundle next to the production one as https://cdn.telemetrydeck.com/websdk/telemetrydeck-beta-<branch>.min.js, so a change can be tried on real sites before it is merged and deployed. Beta files are cached for a minute only, fork pull requests are skipped because they do not receive the CDN secret, and the job summary shows a ready-to-paste script tag. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
1 parent c9e6f05 commit 68cdd27

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

‎.github/workflows/deploy-beta.yml‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Deploy Beta
2+
3+
# Publishes the bundle of a pull request next to the production one as
4+
# https://cdn.telemetrydeck.com/websdk/telemetrydeck-beta-<branch>.min.js
5+
# so it can be tried on real sites before it reaches telemetrydeck.min.js.
6+
# The production deploy (deploy.yml) publishes main as telemetrydeck.min.js.
7+
8+
on:
9+
pull_request:
10+
types: [opened, synchronize, reopened]
11+
12+
concurrency:
13+
group: deploy-beta-${{ github.head_ref }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
upload:
18+
name: Building and Uploading Beta
19+
runs-on: ubuntu-latest
20+
# Pull requests from forks do not get the CDN secret.
21+
if: github.event.pull_request.head.repo.full_name == github.repository
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: pnpm/action-setup@v4
25+
with:
26+
version: 8
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
cache: pnpm
31+
- run: pnpm install
32+
- run: pnpm build
33+
34+
- name: Name the beta file after the branch
35+
id: beta
36+
env:
37+
BRANCH: ${{ github.head_ref }}
38+
run: |
39+
# Keep the URL simple: lowercase letters, digits and single dashes.
40+
branch="$(printf '%s' "$BRANCH" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//')"
41+
if [ -z "$branch" ]; then
42+
echo "Branch name '$BRANCH' leaves nothing usable for a file name." >&2
43+
exit 1
44+
fi
45+
file="telemetrydeck-beta-${branch}.min.js"
46+
mkdir websdk
47+
mv dist/telemetrydeck.min.js "websdk/${file}"
48+
echo "file=$file" >> "$GITHUB_OUTPUT"
49+
echo "url=https://cdn.telemetrydeck.com/websdk/${file}" >> "$GITHUB_OUTPUT"
50+
51+
- uses: bacongobbler/azure-blob-storage-upload@main
52+
with:
53+
source_dir: websdk
54+
container_name: websdk
55+
account_name: telemetrydeckcdn
56+
sas_token: ${{ secrets.CDN_AZURE_SAS_TOKEN }}
57+
overwrite: 'true'
58+
# Beta builds change with every push; keep the CDN from holding on to them.
59+
extra_args: --content-cache-control "public, max-age=60"
60+
61+
- name: Summary
62+
run: |
63+
{
64+
echo "### Beta build published"
65+
echo
66+
echo "Load it on a test page with:"
67+
echo
68+
echo '```html'
69+
echo "<script async src=\"${{ steps.beta.outputs.url }}\" data-app-id=\"<YOUR APP ID>\"></script>"
70+
echo '```'
71+
} >> "$GITHUB_STEP_SUMMARY"

0 commit comments

Comments
 (0)