Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/cdn-dryrun.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CDN Dry-Run

on:
pull_request:
paths:
- "packages/widget/**"
- "packages/sdk/**"
- ".github/workflows/cdn-dryrun.yml"
- ".github/workflows/npm-publish.yml"
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
dryrun-widget:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6

- uses: oven-sh/setup-bun@v2
with:
bun-version: "1.3.13"

- run: bun install

- run: bun run build

- name: Configure AWS credentials (read-only)
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.CDN_AWS_ROLE_READER }}
role-session-name: gha-cdn-dryrun-widget-${{ github.run_id }}
aws-region: ${{ secrets.CDN_AWS_REGION }}

- name: List existing widget objects at CDN
env:
BUCKET: ${{ secrets.CDN_S3_BUCKET }}
run: |
echo "::group::existing s3://${BUCKET}/widgets/"
aws s3 ls "s3://${BUCKET}/widgets/" --recursive --human-readable --summarize || echo "(no widgets at CDN yet)"
echo "::endgroup::"

- name: Dry-run widget sync
env:
BUCKET: ${{ secrets.CDN_S3_BUCKET }}
run: |
VER=$(node -p "require('./packages/widget/package.json').version")
echo "Would publish widget v${VER}"
echo "::group::dryrun → s3://${BUCKET}/widgets/v${VER}/"
aws s3 sync ./packages/widget/dist/ "s3://${BUCKET}/widgets/v${VER}/" --dryrun
echo "::endgroup::"
echo "::group::dryrun → s3://${BUCKET}/widgets/latest/"
aws s3 sync ./packages/widget/dist/ "s3://${BUCKET}/widgets/latest/" --dryrun
echo "::endgroup::"
20 changes: 18 additions & 2 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ name: npm Publish
on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: write
Expand Down Expand Up @@ -97,7 +98,9 @@ jobs:

publish-cdn-widget:
needs: release-please
if: needs.release-please.outputs.widget--release_created == 'true'
if: |
needs.release-please.outputs.widget--release_created == 'true' ||
github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -113,6 +116,19 @@ jobs:

- run: bun run build

- name: Resolve widget version
id: ver
env:
RELEASE_VERSION: ${{ needs.release-please.outputs.widget--version }}
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VER=$(node -p "require('./packages/widget/package.json').version")
else
VER="${RELEASE_VERSION}"
fi
echo "version=${VER}" >> $GITHUB_OUTPUT
echo "Resolved widget version: ${VER}"

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
Expand All @@ -123,7 +139,7 @@ jobs:
- name: Upload widget bundle to CDN (versioned + latest)
env:
BUCKET: ${{ secrets.CDN_S3_BUCKET }}
VERSION: ${{ needs.release-please.outputs.widget--version }}
VERSION: ${{ steps.ver.outputs.version }}
run: |
aws s3 sync ./packages/widget/dist/ "s3://${BUCKET}/widgets/v${VERSION}/" --delete
aws s3 sync ./packages/widget/dist/ "s3://${BUCKET}/widgets/latest/" --delete
Expand Down