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
27 changes: 22 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read
Expand All @@ -15,11 +16,13 @@ concurrency:

jobs:
verify:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- name: Check out repository
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Set up Bun
uses: oven-sh/setup-bun@v2
Expand All @@ -29,9 +32,6 @@ jobs:
- name: Install dependencies
run: bun install --frozen-lockfile

- name: Install Chromium
run: bunx playwright install --with-deps chromium

- name: Run unit tests
run: bun test

Expand All @@ -47,5 +47,22 @@ jobs:
- name: Run Cloudflare integration tests
run: bun run test:cf

- name: Verify Cloudflare deployment bundle
run: bunx wrangler deploy --dry-run --outdir .wrangler/deploy-check

- name: Install Chromium
run: bunx playwright install --with-deps chromium

- name: Run browser tests
run: bun run test:e2e

- name: Upload browser failure artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-artifacts-${{ github.run_id }}
path: |
playwright-report/
test-results/
if-no-files-found: ignore
retention-days: 7
119 changes: 119 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
name: Deploy production

on:
workflow_dispatch:
inputs:
confirmation:
description: Type "deploy" to confirm a production deployment from main
required: true
type: string

permissions:
contents: read

concurrency:
group: deploy-production
cancel-in-progress: false

jobs:
gate:
runs-on: ubuntu-24.04
timeout-minutes: 2
steps:
- name: Validate deployment request
env:
CONFIRMATION: ${{ inputs.confirmation }}
run: |
if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then
echo "::error::Production deployments must run from the main branch."
exit 1
fi
if [[ "$CONFIRMATION" != "deploy" ]]; then
echo "::error::Enter deploy in the confirmation field."
exit 1
fi

deploy:
needs: gate
runs-on: ubuntu-24.04
timeout-minutes: 20
environment:
name: production
steps:
- name: Validate deployment credentials
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: |
if [[ -z "$CLOUDFLARE_API_TOKEN" ]]; then
echo "::error::Missing production environment secret CLOUDFLARE_API_TOKEN."
exit 1
fi
if [[ -z "$CLOUDFLARE_ACCOUNT_ID" ]]; then
echo "::error::Missing production environment secret CLOUDFLARE_ACCOUNT_ID."
exit 1
fi

- name: Check out repository
uses: actions/checkout@v6
with:
persist-credentials: false

- name: Set up Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.14

- name: Install dependencies
run: bun install --frozen-lockfile

- name: Run unit tests
run: bun test

- name: Run type and Svelte checks
run: bun run check

- name: Run lint
run: bun run lint

- name: Build
run: bun run build

- name: Run Cloudflare integration tests
run: bun run test:cf

- name: Verify Cloudflare deployment bundle
run: bunx wrangler deploy --dry-run --outdir .wrangler/deploy-check

- name: Install Chromium
run: bunx playwright install --with-deps chromium

- name: Run browser tests
run: bun run test:e2e

- name: Deploy Worker
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
run: bunx wrangler deploy --strict --message "GitHub Actions ${GITHUB_SHA}"

- name: Record deployment summary
run: |
{
echo "### SubMan production deployment"
echo ""
echo "- Commit: \`${GITHUB_SHA}\`"
echo "- Workflow run: \`${GITHUB_RUN_ID}\`"
echo "- Environment: \`production\`"
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload browser failure artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: deploy-playwright-artifacts-${{ github.run_id }}
path: |
playwright-report/
test-results/
if-no-files-found: ignore
retention-days: 7
Loading
Loading