Wait for Cloudflare Pages deployment in GitHub Actions
2 minutes read
If you deploy to Cloudflare Pages and run end-to-end tests, smoke checks or cache purges afterwards, you've probably seen the workflow move on to the next step before Cloudflare has finished building the site.
Cloudflare deploys asynchronously, so the workflow doesn't wait for the Pages check on that commit to finish. Any step that hits the live URL can end up testing an old deployment, or one that doesn't exist yet.
I fixed it with a small reusable GitHub Actions workflow.
The problem
A typical CD pipeline for a Cloudflare Pages project looks roughly like this:
→ push → build → trigger Cloudflare Pages deployment
→ run E2E tests (against live URLs)
The deploy step starts Cloudflare's build and returns almost straight away. When the tests start, the deployment is usually still running, and you get flaky results and false failures that are a pain to debug.
You need a step between deploy and run tests that waits. It polls GitHub's Checks API until the Cloudflare Pages check run for the current commit has finished.
The solution
I wrote a reusable composite action, actions/wait-cf-pages-deployment, in my shared workflows repository.
It polls the Checks API for the Cloudflare Pages check run on the current commit and blocks the workflow until one of these happens:
- The check run completes with a
successconclusion - The check run completes with any other conclusion, and the step fails
- The polling timeout is reached
Inputs:
| Input | Required | Description |
|---|---|---|
github-token |
No | github-token to use for GitHub API calls |
Usage
Add it as a step in your workflow:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Wait for Cloudflare Pages deployment
uses: jabranr/workflows/.github/actions/wait-cf-pages-deployment@main
with:
github-token: $
- name: Run E2E tests
run: npm run test:e2e
The E2E tests won't start until the wait step passes, and it only passes once the Cloudflare Pages check run has succeeded.
How the polling works
The action calls the Checks API endpoint for the current commit:
GET /repos/{owner}/{repo}/commits/{ref}/check-runs
It finds the Cloudflare Pages check run in the response, checks that its status is completed, then checks that the conclusion is success.
It polls every 15 seconds for up to 2 minutes, and stops as soon as the check finishes or the time runs out.
References
- actions/wait-cf-pages-deployment on GitHub
- GitHub Checks API documentation
- GitHub Actions: reusable workflows
Updated 2026-04-22: corrected technical errors in an earlier version of this post.