Skip to content

feat(audience): add screenDensity to context collection for improved … #26

feat(audience): add screenDensity to context collection for improved …

feat(audience): add screenDensity to context collection for improved … #26

name: Deploy Pixel to CDN
on:
push:
paths:
- "packages/audience/pixel/**"
- "packages/audience/core/**"
branches:
- main
workflow_dispatch:
permissions: {}
concurrency:
group: deploy-pixel-cdn
cancel-in-progress: false
jobs:
deploy:
name: Deploy Pixel to CDN
runs-on: ubuntu-latest
environment: cdn-deploy
permissions:
id-token: write # Required for GitHub OIDC to assume the AWS role
contents: read
env:
S3_BUCKET: audience-pixel-prod
S3_KEY: pixel/v1/imtbl.js
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pin@v6.0.2
with:
persist-credentials: false
- name: setup
uses: ./.github/actions/setup
with:
enable-cache: "false"
- name: Install dependencies
shell: bash
run: pnpm install --frozen-lockfile --ignore-scripts
- name: Build pixel bundle
shell: bash
run: pnpm --filter @imtbl/pixel build
- name: Verify bundle exists
shell: bash
run: |
if [ ! -f packages/audience/pixel/dist/imtbl.js ]; then
echo "::error::Build output not found at packages/audience/pixel/dist/imtbl.js"
exit 1
fi
echo "Bundle size: $(wc -c < packages/audience/pixel/dist/imtbl.js) bytes"
echo "Gzipped size: $(gzip -c packages/audience/pixel/dist/imtbl.js | wc -c) bytes"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@d979d5b3a71173a29b74b5b88418bfda9437d885 # pin@v6.1.1
with:
role-to-assume: ${{ secrets.AWS_IMMUTABLE_PROD_ADMIN_ROLE }}
aws-region: us-east-1
- name: Upload to S3
shell: bash
run: |
aws s3 cp packages/audience/pixel/dist/imtbl.js \
"s3://$S3_BUCKET/$S3_KEY" \
--cache-control "public, max-age=86400" \
--content-type "application/javascript"
- name: Verify S3 upload
shell: bash
run: |
aws s3api head-object \
--bucket "$S3_BUCKET" \
--key "$S3_KEY" \
--query '{ContentType: ContentType, ContentLength: ContentLength, CacheControl: CacheControl}' \
--output table
- name: Invalidate CloudFront cache
env:
CF_DISTRIBUTION_ID: ${{ secrets.CF_PIXEL_PROD_DISTRIBUTION_ID }}
shell: bash
run: |
aws cloudfront create-invalidation \
--distribution-id "$CF_DISTRIBUTION_ID" \
--paths "/$S3_KEY"
- name: Log deployment
shell: bash
run: |
echo "Deployed to: https://cdn.immutable.com/$S3_KEY"