Deploy demo #3
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 demo | |
| on: | |
| workflow_run: | |
| workflows: [CI] | |
| types: [completed] | |
| branches: [main] | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: Git ref to deploy | |
| required: false | |
| default: main | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: deploy-demo-main | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| name: deploy demo static site and API | |
| if: >- | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.event == 'push' && | |
| github.event.workflow_run.head_branch == 'main' && | |
| !startsWith(github.event.workflow_run.head_commit.message, 'chore(release):')) | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 45 | |
| steps: | |
| - uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || github.event.workflow_run.head_sha }} | |
| - uses: actions/setup-node@v7 | |
| with: | |
| node-version: 22 | |
| cache: npm | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Make sure that the Cloudflare zone is active | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
| run: | | |
| curl --fail --silent --show-error \ | |
| --header "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ | |
| "https://api.cloudflare.com/client/v4/zones/${CLOUDFLARE_ZONE_ID}" \ | |
| | jq --exit-status '.success == true and .result.status == "active"' | |
| - name: Deploy the demo API Worker | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: npm run --workspace=@cortex-docs/demo-api deploy | |
| - name: Deploy static.cortexdocs.dev and its referrer registry | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: npm run --workspace=@cortex-docs/demo-api deploy:static | |
| - name: Deploy demo.cortexdocs.dev as assets only | |
| env: | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CORTEX_DEMO_API_URL: https://api.demo.cortexdocs.dev | |
| run: npm run --workspace=@cortex-docs/docs-ui demo:deploy | |
| - name: Verify the deployed demo under concurrent load | |
| run: node scripts/check-demo.mjs https://demo.cortexdocs.dev | |
| - name: Configure demo API security rules | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }} | |
| run: node scripts/configure-cloudflare-security.mjs |