Deploy a site or Worker
A site built on main can deploy as soon as its build succeeds. To tie deployment to a stable release, make it depend on both jobs (needs: [build_site, publish] in the monorepo example) and pass the tag as release-tag. Monorepo workflows
Deployment permissions
Build with check.yml and pass its source-sha and artifact-id to deploy.yml. Use the same config-file for both. Grant write permissions and deployment credentials only to the deploy job.
| Provider | GitHub permissions | Cloudflare token permissions |
|---|---|---|
| GitHub Pages | contents: read, pages: write, id-token: write | — |
| Cloudflare Pages | contents: read | Pages write access on the target account |
| Cloudflare Workers | contents: read | Workers Scripts: Edit on the target account |
Cloudflare production deployments use CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN from repository secrets or organization secrets shared with the repository. Previews use CLOUDFLARE_PREVIEW_ACCOUNT_ID and CLOUDFLARE_PREVIEW_API_TOKEN from the docs-preview environment. See manual previews.
For automatic D1 provisioning, set binding and database_name in d1_databases, omit database_id and grant D1: Edit. Wrangler reuses the named database or creates it if missing.
Deployment policy
Production evaluates artifact.deployment-policy after environment protection rules pass and the job holds the concurrency lock.
| Policy | release-tag | Deployment condition |
|---|---|---|
latest-stable (default) | Required | The tag identifies the latest published stable GitHub Release and resolves to source-sha. An older stable release is skipped. |
always | Supplied | Any published stable GitHub Release whose tag resolves to source-sha. |
always | Omitted | Deploy the artifact for source-sha without a Release lookup, e.g. on a push to main. |
Tagged deployments first skip drafts and prereleases. latest-stable also skips older stable releases. Only then does the job resolve the tag’s commit and compare it with source-sha. A mismatch or a failed lookup at any required step fails the job.
Choose a provider
GitHub Pages
Select github-pages, set artifact.output-directory to the built site and choose GitHub Actions as the source in the repository’s Pages settings. See the monorepo site workflow.
Cloudflare Pages Direct Upload
Set artifact.provider to cloudflare-pages and project-name to an existing Pages project. To deploy from main, filter for that branch in the caller and set deployment-policy: always.
Wrangler uploads the verified payload/ to production and records the source SHA. A root _worker.js file or directory fails validation before upload because Pages treats it as a server entry point.
Cloudflare Workers static assets
Point artifact.output-directory at the built site. Use a standalone Wrangler JSONC file with assets.directory pointing to a subdirectory next to that file. Omit main, build.command and inherited configuration.
The deploy job verifies the same-run artifact’s repository, commit and digest, then restores all files, including dotfiles, under assets.directory in a temporary directory. The official Wrangler Action uploads them with the pinned version, without reinstalling or rebuilding.
Prebuilt Workers
Prebuilt Workers support production only. This artifact section uses the pnpm project setup. wrangler-config is relative to output-directory. server/ and public/ can be siblings.
{
"component": "api",
"kind": "bundle",
"provider": "cloudflare-workers",
"worker-name": "example-api",
"output-directory": ".output",
"wrangler-config": "server/wrangler.json",
"check-command": "pnpm test",
"build-command": "pnpm build"
}
Package main, its imported modules and any declared static assets together. If the build emits multiple modules, add module collection rules to the final Wrangler config.
The deploy job verifies the component, artifact kind, config path in the manifest, Worker name and payload/ digest. It then runs deploy --no-bundle with the pinned Wrangler version in a clean directory.
Manual Cloudflare Workers previews
- Enable the workers.dev preview URL for a dedicated Worker in a separate Cloudflare preview account.
- Set
CLOUDFLARE_PREVIEW_ACCOUNT_IDandCLOUDFLARE_PREVIEW_API_TOKENin thedocs-previewGitHub environment. Limit Worker write access to the preview account. Set the repository variableXOVA_DOCS_PREVIEW_WORKERto the Worker name. - Enter the full commit SHA in the
workflow_dispatchinput. Withrequire-reachable: true, a repository branch or tag must contain the commit. Pass the build’ssource-shaandartifact-idtodeploy.ymlwithtarget: previewand omitrelease-tag.
Check the preview URL and full SHA in the run summary. Previews serve static artifacts only, preserve assets.base_path and exclude production routes and bindings. Deployments from one repository to the same preview Worker run in sequence.
Skip the manual build when the preview variable is unset. A direct call with target: preview fails validation if the variable is missing or blank. For multiple sites, assign distinct artifact.component and artifact-name values.