Mark KV metadata library repository optional #70
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 # Get the full history for the Sentry release commit log | |
| - name: Install Node.js | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.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@dab6548b3c03c4717878099e43782cf5be654289 # v3.5.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' }} |