Skip to content

Include cdnjs.dev/* route for staging #139

Include cdnjs.dev/* route for staging

Include cdnjs.dev/* route for staging #139

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: Run Tests (local)
run: npm test
- 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' }}