Skip to content

Fix mobile layout issues on library website React output (#274) #164

Fix mobile layout issues on library website React output (#274)

Fix mobile layout issues on library website React output (#274) #164

Workflow file for this run

name: Deploy
on:
push:
branches:
- production
- staging
jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: ${{ github.ref_name }}
url: ${{ github.ref_name == 'production' && 'https://api.cdnjs.com/health' || 'https://api.cdnjs.dev/health' }}
steps:
- name: Checkout Commit
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0 # Get the full history for the Sentry release commit log
- name: Install Node.js
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
cache: npm
- name: Install Dependencies
run: npm ci
- name: Install Playwright Chromium
run: npx playwright install --with-deps chromium --only-shell
- name: Run Tests (local)
run: npm test
- name: Run Web Tests (local)
id: web-tests-local
run: npm run test:web
- name: Deploy to ${{ github.ref_name }}
run: npx wrangler deploy --env ${{ github.ref_name }} --outdir dist-worker --minify --var SENTRY_DSN:${{ secrets.SENTRY_DSN }} --var SENTRY_RELEASE:${{ github.sha }}
env:
CLOUDFLARE_API_TOKEN: ${{ github.ref_name == 'production' && secrets.CLOUDFLARE_API_TOKEN_PRODUCTION || secrets.CLOUDFLARE_API_TOKEN_STAGING }}
CLOUDFLARE_ACCOUNT_ID: ${{ github.ref_name == 'production' && secrets.CLOUDFLARE_ACCOUNT_ID_PRODUCTION || secrets.CLOUDFLARE_ACCOUNT_ID_STAGING }}
- name: Create Sentry Release
uses: getsentry/action-release@ff07929a6537bac57790c3451cf4d364aca38528 # v3.7.0
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: cdnjs
SENTRY_PROJECT: api-worker
with:
ignore_missing: true
ignore_empty: true
inject: false
release: ${{ github.sha }}
environment: ${{ github.ref_name }}
sourcemaps: dist-worker
strip_common_prefix: true
- name: Wait for Deployment
run: |
echo "Waiting for deployment to be available..."
until curl -sfI "${{ github.ref_name == 'production' && 'https://api.cdnjs.com/health' || 'https://api.cdnjs.dev/health' }}" | grep -q "x-release: ${{ github.sha }}"; do
echo "Deployment not ready yet. Retrying in 5 seconds..."
sleep 5
done
echo "Deployment is ready!"
timeout-minutes: 5
- name: Run Tests (deployed)
run: npm test
env:
VITEST_EXTERNAL_API_URL: ${{ github.ref_name == 'production' && 'https://api.cdnjs.com' || 'https://api.cdnjs.dev' }}
- name: Run Web Tests (deployed)
id: web-tests-deployed
if: github.ref_name == 'staging'
run: npm run test:web
env:
PLAYWRIGHT_EXTERNAL_WEB_URL: ${{ github.ref_name == 'production' && 'https://cdnjs.com' || 'https://cdnjs.dev' }}
- name: Upload Test Results
if: always() && (steps.web-tests-local.outcome == 'failure' || steps.web-tests-local.outcome == 'success' || steps.web-tests-deployed.outcome == 'failure' || steps.web-tests-deployed.outcome == 'success')
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: playwright-report-${{ github.run_id }}
path: .playwright/report
retention-days: ${{ case(steps.web-tests-local.outcome == 'success' && steps.web-tests-deployed.outcome == 'success', 1, 3) }}