Skip to content

Commit f79e3dc

Browse files
ci(audience): add CDN deploy workflow (SDK-130) (#2863)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent abae76b commit f79e3dc

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy Audience SDK to CDN
2+
3+
on:
4+
push:
5+
paths:
6+
- "packages/audience/sdk/**"
7+
- "packages/audience/core/**"
8+
branches:
9+
- main
10+
workflow_dispatch:
11+
12+
# Required for GitHub OIDC to assume the AWS role
13+
permissions:
14+
id-token: write
15+
contents: read
16+
17+
concurrency:
18+
group: deploy-audience-cdn
19+
cancel-in-progress: false
20+
21+
jobs:
22+
deploy:
23+
runs-on: ubuntu-latest
24+
env:
25+
AWS_REGION: us-east-1
26+
S3_BUCKET: audience-sdk-prod
27+
S3_KEY: audience/v1/imtbl.js
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.1
31+
32+
- name: setup
33+
uses: ./.github/actions/setup
34+
35+
- name: Build audience SDK bundle
36+
run: pnpm --filter @imtbl/audience build
37+
38+
- name: Verify bundle exists
39+
run: |
40+
if [ ! -f packages/audience/sdk/dist/cdn/imtbl-audience.global.js ]; then
41+
echo "::error::Build output not found at packages/audience/sdk/dist/cdn/imtbl-audience.global.js"
42+
exit 1
43+
fi
44+
echo "Bundle size: $(wc -c < packages/audience/sdk/dist/cdn/imtbl-audience.global.js) bytes"
45+
echo "Gzipped size: $(gzip -c packages/audience/sdk/dist/cdn/imtbl-audience.global.js | wc -c) bytes"
46+
47+
- name: Configure AWS credentials
48+
uses: aws-actions/configure-aws-credentials@ececac1a45f3b08a01d2dd070d28d111c5fe6722 # pin@v4.1.0
49+
with:
50+
role-to-assume: ${{ secrets.AWS_IMMUTABLE_PROD_ADMIN_ROLE }}
51+
aws-region: ${{ env.AWS_REGION }}
52+
53+
- name: Upload to S3
54+
run: |
55+
aws s3 cp packages/audience/sdk/dist/cdn/imtbl-audience.global.js \
56+
s3://${{ env.S3_BUCKET }}/${{ env.S3_KEY }} \
57+
--cache-control "public, max-age=86400" \
58+
--content-type "application/javascript"
59+
60+
- name: Verify S3 upload
61+
run: |
62+
aws s3api head-object \
63+
--bucket ${{ env.S3_BUCKET }} \
64+
--key ${{ env.S3_KEY }} \
65+
--query '{ContentType: ContentType, ContentLength: ContentLength, CacheControl: CacheControl}' \
66+
--output table
67+
68+
- name: Invalidate CloudFront cache
69+
run: |
70+
aws cloudfront create-invalidation \
71+
--distribution-id ${{ secrets.CF_PIXEL_PROD_DISTRIBUTION_ID }} \
72+
--paths "/${{ env.S3_KEY }}"
73+
74+
- name: Log deployment
75+
run: |
76+
echo "Deployed to: https://cdn.immutable.com/${{ env.S3_KEY }}"

0 commit comments

Comments
 (0)