Skip to content

Commit 5215bd3

Browse files
committed
Add support for env vars and secrets to Deploy to Cloudflare
1 parent 2ea851a commit 5215bd3

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/content/docs/workers/platform/deploy-buttons.mdx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@ If you're building a Workers application and would like to share it with other d
1414
[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/templates/tree/main/saas-admin-template)
1515

1616
## What are Deploy to Cloudflare buttons?
17+
1718
Deploy to Cloudflare buttons simplify the deployment of a Workers application by enabling Cloudflare to:
18-
* **Clone a Git repository**: Cloudflare clones your source repository into the user's GitHub/GitLab account where they can continue development after deploying.
19-
* **Configure a project**: Your users can customize key details such as repository name, Worker name, and required resource names in a single setup page with customizations reflected in the newly created Git repository.
20-
* **Build & deploy**: Cloudflare builds the application using [Workers Builds](/workers/ci-cd/builds) and deploys it to the Cloudflare network. Any required resources are automatically provisioned and bound to the Worker without additional setup.
19+
20+
- **Clone a Git repository**: Cloudflare clones your source repository into the user's GitHub/GitLab account where they can continue development after deploying.
21+
- **Configure a project**: Your users can customize key details such as repository name, Worker name, and required resource names in a single setup page with customizations reflected in the newly created Git repository.
22+
- **Build & deploy**: Cloudflare builds the application using [Workers Builds](/workers/ci-cd/builds) and deploys it to the Cloudflare network. Any required resources are automatically provisioned and bound to the Worker without additional setup.
2123

2224
![Deploy to Cloudflare Flow](~/assets/images/workers/dtw-user-flow.png)
2325

2426
## How to Set Up Deploy to Cloudflare buttons
25-
Deploy to Cloudflare buttons can be embedded anywhere developers might want to launch your project. To add a Deploy to Cloudflare button, copy the following snippet and replace the Git repository URL with your project's URL. You can also optionally specify a subdirectory.
2627

28+
Deploy to Cloudflare buttons can be embedded anywhere developers might want to launch your project. To add a Deploy to Cloudflare button, copy the following snippet and replace the Git repository URL with your project's URL. You can also optionally specify a subdirectory.
2729

2830
<Tabs syncKey="DeployButtonSnippet">
2931
<TabItem label="Markdown">
@@ -53,34 +55,37 @@ If you have already deployed your application using Workers Builds, you can gene
5355
Once you have your snippet, you can paste this wherever you would like your button to be displayed.
5456

5557
## Automatic Resource provisioning
58+
5659
If your Worker application requires Cloudflare resources, they will be automatically provisioned as part of the deployment. Currently, supported resources include:
57-
* **Storage**: [KV namespaces](/kv/), [D1 databases](/d1/), [R2 buckets](/r2/), [Hyperdrive](/hyperdrive/), and [Vectorize databases](/vectorize/)
58-
* **Compute**: [Durable Objects](/durable-objects/), [Workers AI](/workers-ai/), and [Queues](/queues/)
60+
61+
- **Storage**: [KV namespaces](/kv/), [D1 databases](/d1/), [R2 buckets](/r2/), [Hyperdrive](/hyperdrive/), [Vectorize databases](/vectorize/), [Workers Secrets](/workers/configuration/secrets/), [Workers Environment Variables](/workers/configuration/environment-variables/), and [Secrets Store Secrets](/secrets-store/)
62+
- **Compute**: [Durable Objects](/durable-objects/), [Workers AI](/workers-ai/), and [Queues](/queues/)
5963

6064
Cloudflare will read the Wrangler configuration file of your source repo to determine resource requirements for your application. During deployment, Cloudflare will provision any necessary resources and update the Wrangler configuration where applicable for newly created resources (e.g. database IDs and namespace IDs). To ensure successful deployment, please make sure your source repository includes default values for resource names, resource IDs and any other properties for each binding.
6165

6266
## Best practices
63-
**Configuring Build/Deploy commands**: If you are using custom `build` and `deploy` scripts in your package.json (for example, if using a full stack framework or running D1 migrations), Cloudflare will automatically detect and pre-populate the build and deploy fields. Users can choose to modify or accept the custom commands during deployment configuration.
67+
68+
**Configuring Build/Deploy commands**: If you are using custom `build` and `deploy` scripts in your package.json (for example, if using a full stack framework or running D1 migrations), Cloudflare will automatically detect and pre-populate the build and deploy fields. Users can choose to modify or accept the custom commands during deployment configuration.
6469

6570
If no `deploy` script is specified, Cloudflare will preconfigure `npx wrangler deploy` by default. If no `build` script is specified, Cloudflare will leave this field blank.
6671

6772
**Running D1 Migrations**: If you would like to run migrations as part of your setup, you can specify this in your `package.json` by running your migrations as part of your `deploy` script. The migration command should reference the binding name rather than the database name to ensure migrations are successful when users specify a database name that is different from that of your source repository. The following is an example of how you can set up the scripts section of your `package.json`:
6873

6974
```json
7075
{
71-
"scripts": {
72-
"build": "astro build",
73-
"deploy": "npm run db:migrations:apply && wrangler deploy",
74-
"db:migrations:apply": "wrangler d1 migrations apply DB_BINDING --remote"
75-
}
76+
"scripts": {
77+
"build": "astro build",
78+
"deploy": "npm run db:migrations:apply && wrangler deploy",
79+
"db:migrations:apply": "wrangler d1 migrations apply DB_BINDING --remote"
80+
}
7681
}
7782
```
7883

7984
## Limitations
8085

81-
* **Monorepos**: Cloudflare does not fully support monorepos
82-
* If your repository URL contains a subdirectory, your application must be fully isolated within that subdirectory, including any dependencies. Otherwise, the build will fail. Cloudflare treats this subdirectory as the root of the new repository created as part of the deploy process.
83-
* Additionally, if you have a monorepo that contains multiple Workers applications, they will not be deployed together. You must configure a separate Deploy to Cloudflare button for each application. The user will manually create a distinct Workers application for each subdirectory.
84-
* **Pages applications**: Deploy to Cloudflare buttons only support Workers applications.
85-
* **Non-GitHub/GitLab repositories**: Source repositories from anything other than github.com and gitlab.com are not supported. Self-hosted versions of GitHub and GitLab are also not supported.
86-
* **Private repositories**: Repositories must be public in order for others to successfully use your Deploy to Cloudflare button.
86+
- **Monorepos**: Cloudflare does not fully support monorepos
87+
- If your repository URL contains a subdirectory, your application must be fully isolated within that subdirectory, including any dependencies. Otherwise, the build will fail. Cloudflare treats this subdirectory as the root of the new repository created as part of the deploy process.
88+
- Additionally, if you have a monorepo that contains multiple Workers applications, they will not be deployed together. You must configure a separate Deploy to Cloudflare button for each application. The user will manually create a distinct Workers application for each subdirectory.
89+
- **Pages applications**: Deploy to Cloudflare buttons only support Workers applications.
90+
- **Non-GitHub/GitLab repositories**: Source repositories from anything other than github.com and gitlab.com are not supported. Self-hosted versions of GitHub and GitLab are also not supported.
91+
- **Private repositories**: Repositories must be public in order for others to successfully use your Deploy to Cloudflare button.

0 commit comments

Comments
 (0)