Skip to content

GitHub integration

Last updated View as MarkdownAgent setup

Cloudflare supports connecting your GitHub repository to your Cloudflare Worker, and will automatically deploy your code every time you push a change.

Features

Beyond automatic builds and deployments, the Cloudflare GitHub integration lets you monitor builds directly in GitHub, keeping you informed without leaving your workflow.

Pull request comment

If a commit is on a pull request, Cloudflare will automatically post a comment on the pull request with the status of the build.

GitHub pull request comment

A Preview URL will be provided for builds which perform wrangler preview. This is useful when reviewing your pull request, as it lets you test the code changes in an isolated copy of your Worker.

Subsequent pushes to the same branch update the same Preview URL. Each deployment also gets an immutable Deployment URL for testing one exact deployment.

The comment lists URLs for every host enabled for Previews on your Worker. This can be a custom domain, workers.dev, or both. A custom domain alone is enough.

If the comment shows No Preview URL for a successful build, refer to Troubleshooting.

Comment history reveals any builds completed earlier while the PR was open.

GitHub pull request comment history

Check run

If you have one or multiple Workers connected to a repository (i.e. a monorepo), you can check on the status of each build within GitHub via GitHub check runs ↗︎.

You can see the checks by selecting on the status icon next to a commit within your GitHub repository. In the example below, you can select the green check mark to see the results of the check run.

GitHub status

Check runs will appear like the following in your repository. You can select Details to view the build (Build ID) and project (Script) associated with each check.

GitHub check runs

Note that when using build watch paths, only projects that trigger a build will generate a check run.

Manage access

You can deploy projects to Cloudflare Workers from your company or side project on GitHub using the Cloudflare Workers & Pages GitHub App ↗︎.

Install and authorize the app

To connect a repository, the Cloudflare Workers & Pages app must be installed on the GitHub account or organization that owns it, and you must authorize the app with your own GitHub user. These are separate steps, and they appear on separate tabs in your GitHub settings.

Authorize: tells Cloudflare who you are, once per person, listed under Authorized GitHub Apps. Install: decides which repositories Cloudflare can access, listed under Installed GitHub Apps.
Install the app Authorize the app
What it does Gives Cloudflare access to repositories on a GitHub account or organization. Tells Cloudflare who you are on GitHub, so you only see the accounts and repositories you can access.
Who does it An owner of the GitHub account or organization, or a member with the GitHub App manager role ↗︎. Each person who connects a repository from Cloudflare, once.
Choose repositories Yes. Select All repositories or Only select repositories. No.
Where to find it on GitHub Installed GitHub Apps ↗︎. For an organization, select Switch settings context first. Authorized GitHub Apps ↗︎
How to undo it Select Configure, then Uninstall. Select Revoke.

Cloudflare asks you to authorize the app when needed. To install the app on another GitHub account or organization, select Add GitHub account when you connect a repository.

For more information, refer to About using GitHub Apps ↗︎ in the GitHub documentation.

Repository access

When you connect a GitHub repository, you only see the GitHub accounts and repositories you can access on GitHub.

The first time you connect a repository, Cloudflare sends you to GitHub to authorize the Cloudflare Workers & Pages app. You need to do this once, even if someone else on your Cloudflare account already connected GitHub. If the app is not installed on any GitHub account you can access, you also install it on your own GitHub account or an organization.

The account list shows your own GitHub account and organizations where you can access at least one repository, if the app is installed on them. GitHub accounts that belong to other users are not listed, even if they have given you access to one of their repositories.

Authorizing the app is separate from installing it. If your own GitHub account or an organization is missing from the list, select Add GitHub account and install the app on it.

Existing repository connections keep building.

To switch GitHub users, revoke the app on the Authorized GitHub Apps page ↗︎ and connect again.

Organizational access

When authorizing Cloudflare Workers to access a GitHub account, you can specify access to your individual account or an organization that you belong to on GitHub.

To add Cloudflare Workers installation to an organization, your user account must be an owner or have the appropriate role within the organization (i.e. the GitHub Apps Manager role). More information on these roles can be seen on GitHub's documentation ↗︎.

Remove access

You can remove Cloudflare Workers' access to your GitHub repository or account by going to the Applications page ↗︎ on GitHub (if you are in an organization, select Switch settings context to access your GitHub organization settings). The GitHub App is named Cloudflare Workers and Pages, and it is shared between Workers and Pages projects.

Remove Cloudflare access to a GitHub repository

To remove access to an individual GitHub repository, you can navigate to Repository access. Select the Only select repositories option, and configure which repositories you would like Cloudflare to have access to.

GitHub Repository Access

Remove Cloudflare access to the entire GitHub account

To remove Cloudflare Workers and Pages access to your entire Git account, you can navigate to Uninstall "Cloudflare Workers and Pages", then select Uninstall. Removing access to the Cloudflare Workers and Pages app will revoke Cloudflare's access to all repositories from that GitHub account. If you want to only disable automatic builds and deployments, follow the Disable Build instructions.

Note that removing access to GitHub will disable new builds for Workers and Pages projects that were connected to those repositories, though your previous deployments will continue to be hosted by Cloudflare Workers.

Reinstall the Cloudflare GitHub App

When encountering Git integration related issues, one potential troubleshooting step is attempting to uninstall and reinstall the GitHub or GitLab application associated with the Cloudflare Pages installation. The process for each Git provider is provided below.

  1. Go to the installation settings page on GitHub:
    • Navigate to Settings > Builds for the Workers or Pages project and select Manage under Git Repository.
    • Alternatively, visit these links to find the Cloudflare Workers and Pages installation and select Configure:
Individual https://github.com/settings/installations
Organization https://github.com/organizations/<YOUR_ORGANIZATION_NAME>/settings/installations
  1. In the Cloudflare Workers and Pages GitHub App settings page, navigate to Uninstall "Cloudflare Workers and Pages" and select Uninstall.
  2. Go back to the Workers & Pages overview ↗︎ page. Select Create application > Pages > Connect to Git.
  3. Select the + Add account button, select the GitHub account you want to add, and then select Install & Authorize.
  4. You should be redirected to the create project page with your GitHub account or organization in the account list.
  5. Attempt to make a new deployment with your project which was previously broken.

Was this helpful?