diff --git a/src/assets/images/workers/platform/ci-cd/github-pull-request-comment-history.png b/src/assets/images/workers/platform/ci-cd/github-pull-request-comment-history.png new file mode 100644 index 00000000000000..af7ee86c9af939 Binary files /dev/null and b/src/assets/images/workers/platform/ci-cd/github-pull-request-comment-history.png differ diff --git a/src/assets/images/workers/platform/ci-cd/github-pull-request-comment.png b/src/assets/images/workers/platform/ci-cd/github-pull-request-comment.png new file mode 100644 index 00000000000000..afe9c752238598 Binary files /dev/null and b/src/assets/images/workers/platform/ci-cd/github-pull-request-comment.png differ diff --git a/src/content/docs/workers/ci-cd/builds/advanced-setups.mdx b/src/content/docs/workers/ci-cd/builds/advanced-setups.mdx index 88d853f6e75057..77bfc240f9694e 100644 --- a/src/content/docs/workers/ci-cd/builds/advanced-setups.mdx +++ b/src/content/docs/workers/ci-cd/builds/advanced-setups.mdx @@ -3,7 +3,7 @@ pcx_content_type: reference title: Advanced setups description: Learn how to use Workers Builds with more advanced setups sidebar: - order: 7 + order: 8 --- ## Monorepos @@ -53,7 +53,7 @@ You can use [Wrangler Environments](/workers/wrangler/environments/) with Worker 1. [Deploy via Wrangler](/workers/wrangler/commands/#deploy) to create the Workers for your environments on the Dashboard, if you do not already have them. 2. Find the Workers for your environments. They are typically named `[name of Worker] - [environment name]`. 3. Connect your repository to each of the Workers for your environment. -4. In each of the Workers, edit your Wrangler deploy command to include the flag `--env: ` in the build configurations. +4. In each of the Workers, edit your Wrangler commands to include the flag `--env: ` in the build configurations for both the deploy command, and the non-production branch deploy command ([if applicable](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds)). When a new commit is detected in the repository, a new build/deploy will trigger for each associated Worker. @@ -61,4 +61,4 @@ When a new commit is detected in the repository, a new build/deploy will trigger Imagine you have a Worker named `my-worker`, and you want to set up two environments `staging` and `production` set in the `wrangler.toml`. If you have not already, you can deploy `my-worker` for each environment using the commands `wrangler deploy --env staging` and `wrangler deploy --env production`. -In your Cloudflare Dashboard, you should find the two Workers `my-worker-staging` and `my-worker-production`. Then, connect the Git repository for the Worker, `my-worker`, to both of the environment Workers. In the build configurations of each environment Worker, edit the deploy commands to be `npx wrangler deploy --env staging` and `npx wrangler deploy --env production` respectively. +In your Cloudflare Dashboard, you should find the two Workers `my-worker-staging` and `my-worker-production`. Then, connect the Git repository for the Worker, `my-worker`, to both of the environment Workers. In the build configurations of each environment Worker, edit the deploy commands to be `npx wrangler deploy --env staging` and `npx wrangler deploy --env production` and the non-production branch deploy commands to be `npx wrangler versions upload --env staging` and `npx wrangler versions upload --env production` respectively. diff --git a/src/content/docs/workers/ci-cd/builds/build-branches.mdx b/src/content/docs/workers/ci-cd/builds/build-branches.mdx new file mode 100644 index 00000000000000..fcca13fdcb045c --- /dev/null +++ b/src/content/docs/workers/ci-cd/builds/build-branches.mdx @@ -0,0 +1,27 @@ +--- +pcx_content_type: concept +title: Build branches +description: Configure which git branches should trigger a Workers Build +sidebar: + order: 6 +--- + +When you connect a git repository to Workers, commits made on the production git branch will produce a Workers Build. If you want to take advantage of [preview URLs](/workers/configuration/previews/) and [pull request comments](/workers/ci-cd/builds/git-integration/github-integration/#pull-request-comment), you can additionally enable "non-production branch builds" in order to trigger a build on all branches of your repository. + +## Change production branch + +To change the production branch of your project: + +1. In **Overview**, select your Workers project. +2. Go to **Settings** > **Build** > **Branch control**. Workers will default to the default branch of your git repository, but this can be changed in the dropdown. + +Every push event made to this branch will trigger a build and execute the [build command](/workers/ci-cd/builds/configuration/#build-command), followed by the [deploy command](/workers/ci-cd/builds/configuration/#deploy-command). + +## Configure non-production branch builds + +To enable or disable non-production branch builds: + +1. In **Overview**, select your Workers project. +2. Go to **Settings** > **Build** > **Branch control**. The checkbox allows you to enable or disable builds for non-production branches. + +When enabled, every push event made to a non-production branch will trigger a build and execute the [build command](/workers/ci-cd/builds/configuration/#build-command), follwed by the [non-production branch deploy command](/workers/ci-cd/builds/configuration/#non-production-branch-deploy-command). diff --git a/src/content/docs/workers/ci-cd/builds/build-watch-paths.mdx b/src/content/docs/workers/ci-cd/builds/build-watch-paths.mdx index bc437662381b2b..463fb0f096e301 100644 --- a/src/content/docs/workers/ci-cd/builds/build-watch-paths.mdx +++ b/src/content/docs/workers/ci-cd/builds/build-watch-paths.mdx @@ -3,7 +3,7 @@ pcx_content_type: concept title: Build watch paths description: Reduce compute for your monorepo by specifying paths for Workers Builds to skip sidebar: - order: 6 + order: 7 --- When you connect a git repository to Workers, by default a change to any file in the repository will trigger a build. You can configure Workers to include or exclude specific paths to specify if Workers should skip a build for a given path. This can be especially helpful if you are using a monorepo project structure and want to limit the amount of builds being kicked off. diff --git a/src/content/docs/workers/ci-cd/builds/configuration.mdx b/src/content/docs/workers/ci-cd/builds/configuration.mdx index 0e4caca53fcb6b..6dc5c8bcfd8db3 100644 --- a/src/content/docs/workers/ci-cd/builds/configuration.mdx +++ b/src/content/docs/workers/ci-cd/builds/configuration.mdx @@ -18,16 +18,17 @@ Note that when you update and save build settings, the updated settings will be ### Overview -| Setting | Description | -| ---------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| **Git account** | Select the Git account you would like to use. After the initial connection, you can continue to use this Git account for future projects. | -| **Git repository** | Choose the Git repository you would like to connect your Worker to. | -| **Git branch** | Select the branch you would like Cloudflare to listen to for new commits. This will be defaulted to `main`. | -| **Build command** _(Optional)_ | Set a build command if your project requires a build step (e.g. `npm run build`). This is necessary, for example, when using a [front-end framework](/workers/ci-cd/builds/configuration/#framework-support) such as Next.js or Remix. | -| **[Deploy command](/workers/ci-cd/builds/configuration/#deploy-command)** | The deploy command lets you set the [specific Wrangler command](/workers/wrangler/commands/#deploy) used to deploy your Worker. Your deploy command will default to `npx wrangler deploy` but you may customize this command. Workers Builds will use the Wrangler version set in your `package json`. | -| **Root directory** _(Optional)_ | Specify the path to your project. The root directory defines where the build command will be run and can be helpful in [monorepos](/workers/ci-cd/builds/advanced-setups/#monorepos) to isolate a specific project within the repository for builds. | -| **[API token](/workers/ci-cd/builds/configuration/#api-token)** _(Optional)_ | The API token is used to authenticate your build request and authorize the upload and deployment of your Worker to Cloudflare. By default, Cloudflare will automatically generate an API token for your account when using Workers Builds, and continue to use this API token for all subsequent builds. Alternatively, you can [create your own API token](/workers/wrangler/migration/v1-to-v2/wrangler-legacy/authentication/#generate-tokens), or select one that you already own. | -| **Build variables and secrets** _(Optional)_ | Add environment variables and secrets accessible only to your build. Build variables will not be accessible at runtime. If you would like to configure runtime variables you can do so in **Settings** > **Variables & Secrets** | +| Setting | Description | +| --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| **Git account** | Select the Git account you would like to use. After the initial connection, you can continue to use this Git account for future projects. | +| **Git repository** | Choose the Git repository you would like to connect your Worker to. | +| **Git branch** | Select the branch you would like Cloudflare to listen to for new commits. This will be defaulted to `main`. | +| **Build command** _(Optional)_ | Set a build command if your project requires a build step (e.g. `npm run build`). This is necessary, for example, when using a [front-end framework](/workers/ci-cd/builds/configuration/#framework-support) such as Next.js or Remix. | +| **[Deploy command](/workers/ci-cd/builds/configuration/#deploy-command)** | The deploy command lets you set the [specific Wrangler command](/workers/wrangler/commands/#deploy) used to deploy your Worker. Your deploy command will default to `npx wrangler deploy` but you may customize this command. Workers Builds will use the Wrangler version set in your `package json`. | +| **[Non-production branch deploy command](/workers/ci-cd/builds/configuration/#non-production-branch-deploy-command)** | Set a command to run when executing [a build for commit on a non-production branch](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds). This will default to `npx wrangler versions upload` but you may customize this command. Workers Builds will use the Wrangler version set in your `package json`. | +| **Root directory** _(Optional)_ | Specify the path to your project. The root directory defines where the build command will be run and can be helpful in [monorepos](/workers/ci-cd/builds/advanced-setups/#monorepos) to isolate a specific project within the repository for builds. | +| **[API token](/workers/ci-cd/builds/configuration/#api-token)** _(Optional)_ | The API token is used to authenticate your build request and authorize the upload and deployment of your Worker to Cloudflare. By default, Cloudflare will automatically generate an API token for your account when using Workers Builds, and continue to use this API token for all subsequent builds. Alternatively, you can [create your own API token](/workers/wrangler/migration/v1-to-v2/wrangler-legacy/authentication/#generate-tokens), or select one that you already own. | +| **Build variables and secrets** _(Optional)_ | Add environment variables and secrets accessible only to your build. Build variables will not be accessible at runtime. If you would like to configure runtime variables you can do so in **Settings** > **Variables & Secrets** | :::note Currently, Workers Builds does not honor the configurations set in [Custom Builds](/workers/wrangler/custom-builds/) within your wrangler.toml file. @@ -43,10 +44,22 @@ Examples of other deploy commands you can set include: | Example Command | Description | | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `npx wrangler versions upload` | Upload a [version](/workers/configuration/versions-and-deployments/) of your Worker without deploying it as the Active Deployment. | | `npx wrangler deploy --assets ./public/` | Deploy your Worker along with static assets from the specified directory. Alternatively, you can use the [assets binding](/workers/static-assets/binding/). | | `npx wrangler deploy --env staging` | If you have a [Wrangler environment](/workers/ci-cd/builds/advanced-setups/#wrangler-environments) Worker, you should set your deploy command with the environment flag. For more details, see [Advanced Setups](/workers/ci-cd/builds/advanced-setups/#wrangler-environments). | +### Non-production branch deploy command + +The non-production branch deploy command is only applicable when you have enabled [non-production branch builds](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds). + +It defaults to `npx wrangler versions upload`, producing a [preview URL](/workers/configuration/previews/). Like the build and deploy commands, it can be customized to instead run anything. + +Examples of other non-production branch deploy commands you can set include: + +| Example Command | Description | +| -------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `yarn exec wrangler versions upload` | You can customize the package manager used to run Wrangler. | +| `npx wrangler versions upload --env staging` | If you have a [Wrangler environment](/workers/ci-cd/builds/advanced-setups/#wrangler-environments) Worker, you should set your non-production branch deploy command with the environment flag. For more details, see [Advanced Setups](/workers/ci-cd/builds/advanced-setups/#wrangler-environments). | + ### API token The API token in Workers Builds defines the access granted to Workers Builds for interacting with your account's resources. Currently, only user tokens are supported, with account-owned token support coming soon. diff --git a/src/content/docs/workers/ci-cd/builds/git-integration/github-integration.mdx b/src/content/docs/workers/ci-cd/builds/git-integration/github-integration.mdx index 6abd6c2230502e..fe9c9c4ca0e180 100644 --- a/src/content/docs/workers/ci-cd/builds/git-integration/github-integration.mdx +++ b/src/content/docs/workers/ci-cd/builds/git-integration/github-integration.mdx @@ -6,17 +6,23 @@ sidebar: order: 2 --- -Cloudflare supports connecting your GitHub repository to your Cloudflare Worker, and will automatically deploy your code every time you push a change to a selected branch. +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. -:::note[Upcoming features] -In Beta, Workers Builds supports automatic builds and deployments only from a single selected branch (e.g. `main`). +### Pull request comment -Support for building and deploying preview versions from multiple branches will be added soon, along with the ability to generate [Preview URLs](/workers/configuration/previews/) for pull requests (PRs). -::: +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](~/assets/images/workers/platform/ci-cd/github-pull-request-comment.png) + +A [preview URL](/workers/configuration/previews/) will be provided for any builds which perform `wrangler versions upload`. This is particularly useful when reviewing your pull request, as it allows you to compare the code changes alongside an updated version of your Worker. + +Comment history reveals any builds completed earlier while the PR was open. + +![GitHub pull request comment history](~/assets/images/workers/platform/ci-cd/github-pull-request-comment-history.png) ### Check run diff --git a/src/content/docs/workers/ci-cd/builds/git-integration/gitlab-integration.mdx b/src/content/docs/workers/ci-cd/builds/git-integration/gitlab-integration.mdx index 4b77d2ff221b2c..affb9f7c9c946d 100644 --- a/src/content/docs/workers/ci-cd/builds/git-integration/gitlab-integration.mdx +++ b/src/content/docs/workers/ci-cd/builds/git-integration/gitlab-integration.mdx @@ -6,16 +6,15 @@ sidebar: order: 2 --- -Cloudflare supports connecting your GitLab repository to your Cloudflare Worker, and will automatically deploy your code every time you push a change to a selected branch. +Cloudflare supports connecting your GitLab 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 GitLab integration lets you monitor builds directly in GitLab, keeping you informed without leaving your workflow. - :::note[Upcoming features] -In Beta, Workers Builds supports automatic builds and deployments only from a single selected branch (e.g. `main`). +While you can still [enable builds for non-production branches](/workers/ci-cd/builds/build-branches/#configure-non-production-branch-builds), when using GitLab, we don't currently create PR comments. -Support for building and deploying preview versions from multiple branches will be added soon, along with the ability to generate [Preview URLs](/workers/configuration/previews/) for pull requests (PRs). +This feature will be available soon. ::: ### Commit Status @@ -38,7 +37,7 @@ You can deploy projects to Cloudflare Workers from your company or side project ### Organizational access -When you authorize Cloudflare Workers to access your GitLab account, you automatically give Cloudflare Workers access to organizations, groups, and namespaces accessed by your GitLab account. Managing access to these organizations and groups is handled by GitLab. +When you authorize Cloudflare Workers to access your GitLab account, you automatically give Cloudflare Workers access to organizations, groups, and namespaces accessed by your GitLab account. Managing access to these organizations and groups is handled by GitLab. ### Remove access diff --git a/src/content/docs/workers/ci-cd/builds/git-integration/index.mdx b/src/content/docs/workers/ci-cd/builds/git-integration/index.mdx index 1f37ebe8d393aa..c827ab66500a30 100644 --- a/src/content/docs/workers/ci-cd/builds/git-integration/index.mdx +++ b/src/content/docs/workers/ci-cd/builds/git-integration/index.mdx @@ -6,9 +6,9 @@ sidebar: order: 3 --- -Cloudflare supports connecting your [GitHub](/workers/ci-cd/builds/git-integration/github-integration/) and [GitLab](/workers/ci-cd/builds/git-integration/gitlab-integration/) repository to your Cloudflare Worker, and will automatically deploy your code every time you push a change to a selected branch. +Cloudflare supports connecting your [GitHub](/workers/ci-cd/builds/git-integration/github-integration/) and [GitLab](/workers/ci-cd/builds/git-integration/gitlab-integration/) repository to your Cloudflare Worker, and will automatically deploy your code every time you push a change. -Adding a Git integration also lets you monitor build statuses directly in your Git provider using [check runs](/workers/ci-cd/builds/git-integration/github-integration/#check-run) or [commit statuses](/workers/ci-cd/builds/git-integration/gitlab-integration/#commit-status), so you can manage deployments without leaving your workflow. +Adding a Git integration also lets you monitor build statuses directly in your Git provider using [pull request comments](/workers/ci-cd/builds/git-integration/github-integration/#pull-request-comment), [check runs](/workers/ci-cd/builds/git-integration/github-integration/#check-run), or [commit statuses](/workers/ci-cd/builds/git-integration/gitlab-integration/#commit-status), so you can manage deployments without leaving your workflow. ## Supported Git Providers diff --git a/src/content/docs/workers/ci-cd/builds/limits-and-pricing.mdx b/src/content/docs/workers/ci-cd/builds/limits-and-pricing.mdx index 69df3ee2ae442e..f056efa5dad49a 100644 --- a/src/content/docs/workers/ci-cd/builds/limits-and-pricing.mdx +++ b/src/content/docs/workers/ci-cd/builds/limits-and-pricing.mdx @@ -3,23 +3,25 @@ pcx_content_type: concept title: Limits & pricing description: Limits & pricing for Workers Builds sidebar: - order: 8 + order: 9 --- + Workers Builds has the following limits. While in open beta, these limits are subject to change. -| Metric | Free plan | Paid plans | -| ------------------------- | ---------------------- | --------------------------------------- | -| **Build minutes** | 3,000 per month | 6,000 per month (then, +$0.005 per minute) | -| **Concurrent builds** | 1 | 6 | -| **Build timeout** | 20 minutes | 20 minutes | -| **CPU** | 2 CPUs | 2 CPUs | -| **Memory** | 8 GB | 8 GB | -| **Disk space** | 8 GB | 8 GB | +| Metric | Free plan | Paid plans | +| --------------------- | --------------- | ------------------------------------------ | +| **Build minutes** | 3,000 per month | 6,000 per month (then, +$0.005 per minute) | +| **Concurrent builds** | 1 | 6 | +| **Build timeout** | 20 minutes | 20 minutes | +| **CPU** | 2 CPUs | 2 CPUs | +| **Memory** | 8 GB | 8 GB | +| **Disk space** | 8 GB | 8 GB | ## Definitions -* **Build minutes**: The amount of minutes that it takes to build a project. -* **Concurrent builds**: The number of builds that can run in parallel across an account. -* **Build timeout**: The amount of time that a build can be run before it is terminated. -* **CPU**: The number of CPU cores available to your build. -* **Memory**: The amount of memory available to your build. -* **Disk space**: The amount of disk space available to your build. \ No newline at end of file + +- **Build minutes**: The amount of minutes that it takes to build a project. +- **Concurrent builds**: The number of builds that can run in parallel across an account. +- **Build timeout**: The amount of time that a build can be run before it is terminated. +- **CPU**: The number of CPU cores available to your build. +- **Memory**: The amount of memory available to your build. +- **Disk space**: The amount of disk space available to your build. diff --git a/src/content/docs/workers/ci-cd/builds/troubleshoot.mdx b/src/content/docs/workers/ci-cd/builds/troubleshoot.mdx index 4c1bc495026ef5..f647dff44c8a25 100644 --- a/src/content/docs/workers/ci-cd/builds/troubleshoot.mdx +++ b/src/content/docs/workers/ci-cd/builds/troubleshoot.mdx @@ -3,7 +3,7 @@ pcx_content_type: troubleshooting title: Troubleshooting builds description: Learn how to troubleshoot common and known issues in Workers Builds. sidebar: - order: 9 + order: 10 --- This guide explains how to identify and resolve build errors, as well as troubleshoot common issues in the Workers Builds deployment process.