Skip to content

Cloudflare Pages and Workers

Run Smoketest after Cloudflare Pages or Workers deployments.

View as Markdown

Cloudflare Pages and Workers can be deployed from Git, deploy hooks, Wrangler, or CI. Use Smoketest after the deployment is live.

Pages with GitHub Actions

.github/workflows/cloudflare-pages-smoketest.yml
name: Deploy Pages and run Smoketest

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy Pages
        run: npx wrangler pages deploy dist --project-name "$CLOUDFLARE_PAGES_PROJECT"
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          CLOUDFLARE_PAGES_PROJECT: acme-site
      - name: Trigger Smoketest
        run: |
          curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
            -H "Idempotency-Key: ${{ github.run_id }}-${{ github.run_attempt }}" \
            --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
            --data-urlencode "commitSha=${{ github.sha }}" \
            --data-urlencode "branch=${{ github.ref_name }}" \
            --data-urlencode "externalId=${{ github.run_id }}-${{ github.run_attempt }}"
        env:
          SMOKETEST_DEPLOYMENT_WEBHOOK_URL: ${{ secrets.SMOKETEST_DEPLOYMENT_WEBHOOK_URL }}
          DEPLOYMENT_URL: https://www.example.com

Workers with Wrangler

.github/workflows/cloudflare-workers-smoketest.yml
name: Deploy Worker and run Smoketest

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Deploy Worker
        run: npx wrangler deploy
        env:
          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
      - name: Trigger Smoketest
        run: |
          curl -sf -X POST -G "$SMOKETEST_DEPLOYMENT_WEBHOOK_URL" \
            -H "Idempotency-Key: ${{ github.run_id }}-${{ github.run_attempt }}" \
            --data-urlencode "targetUrl=$DEPLOYMENT_URL" \
            --data-urlencode "commitSha=${{ github.sha }}" \
            --data-urlencode "branch=${{ github.ref_name }}" \
            --data-urlencode "externalId=${{ github.run_id }}-${{ github.run_attempt }}"
        env:
          SMOKETEST_DEPLOYMENT_WEBHOOK_URL: ${{ secrets.SMOKETEST_DEPLOYMENT_WEBHOOK_URL }}
          DEPLOYMENT_URL: https://api.example.com

Cloudflare deploy hooks

Cloudflare deploy hooks trigger Cloudflare deployments; they are not post-deploy notifications to Smoketest. Use your CI pipeline after deployment, or trigger Smoketest from the same script that calls the Cloudflare deploy hook after the site is reachable.

On this page