strapi-plugin-cloudflare-deploy
v1.0.0
Published
A plugin to trigger Cloudflare Worker and Pages builds from Strapi.
Downloads
64
Maintainers
Readme
Strapi Plugin Cloudflare Deploy
A plugin to trigger Cloudflare Worker and Pages builds from Strapi.
Note: This plugin is inspired by strapi-plugin-cloudflare-pages. This version adds support for the newer Cloudflare Workers (in addition to Pages) and is built for Strapi v5.
Features
- Trigger Cloudflare Workers builds via API
- Trigger Cloudflare Pages deployments via webhooks
- Multiple deployment instances support
- Branch-specific Worker deployments
Requirements
- Strapi v5
- Cloudflare account with a Workers or Pages project
Installation
npm install strapi-plugin-cloudflare-deploy
# or
yarn add strapi-plugin-cloudflare-deployAfter installation, rebuild your Strapi admin panel:
npm run build
# or
yarn buildConfiguration
Configure the plugin in your config/plugins.ts (examples shown for TypeScript):
export default ({ env }) => ({
'cloudflare-deploy': {
enabled: true,
config: {
// Account Id and Api Token are only required for Worker instances
accountId: env('CF_ACCOUNT_ID'),
apiToken: env('CF_API_TOKEN'),
instances: [
{
type: 'worker',
name: 'Production Worker',
triggerUuid: '1cf3cac4-some-trigger-uuid',
branch: 'main'
},
{
type: 'pages',
name: 'Production Site',
deployHookUrl: env('CF_PAGES_DEPLOY_HOOK')
}
]
}
}
});Configuration Options
| Property | Type | Required | Description | | --------- | ------ | ----------- | ---------------------------------------- | | accountId | string | For Workers | Cloudflare Account ID | | apiToken | string | For Workers | API token with Workers Builds permission | | instances | array | Yes | Array of deployment targets |
Worker Instance Options
| Property | Type | Required | Description |
| ----------- | ---------- | -------- | ---------------------------------- |
| type | 'worker' | Yes | Instance type |
| name | string | Yes | Display name in the admin panel |
| triggerUuid | string | Yes | Build trigger UUID from Cloudflare |
| branch | string | No | Git branch to deploy |
Pages Instance Options
| Property | Type | Required | Description |
| ------------- | --------- | -------- | ------------------------------------ |
| type | 'pages' | Yes | Instance type |
| name | string | Yes | Display name in the admin panel |
| deployHookUrl | string | Yes | Full deploy hook URL from Cloudflare |
Obtaining Cloudflare Credentials
Account ID
See Find account and zone IDs in the Cloudflare docs.
API Token (for Workers)
This plugin requires a user API token (account API tokens don't seem to work right now).
- Navigate to User API Tokens in your Cloudflare profile
- Click Create Token > Create Custom Token
- Set the following permissions:
- Account > Workers Builds Configuration > Edit
- Account > Workers Scripts > Read (only required for the configuration script)
- Click Continue to summary and Create Token
- Copy the token immediately (it is only shown once)
Worker Instance Configuration
Use the helper script to generate the instance configuration. You can run it directly without cloning the repository:
curl -fsSL https://raw.githubusercontent.com/Kage0x3B/strapi-plugin-cloudflare-deploy/refs/heads/main/generate-cloudflare-worker-config.sh | shOr if you have the repository cloned:
./generate-cloudflare-worker-config.shSecurity Note: Before running scripts from the internet, you should review them first. You can view the script source here. The script only makes read-only requests to two Cloudflare APIs to list your Workers and fetch their build triggers — it does not modify anything.
The script will:
- Prompt for your Account ID and API Token
- Verify your token and check permissions
- List your Workers and let you select one (supports
fzffor interactive selection) - List available build triggers and let you select one
- Output a ready-to-use instance config
Example output:
{
name: "my-worker",
type: "worker",
triggerUuid: "abc123-def456-...",
branch: "main",
}Copy this into your plugin configuration's instances array. You may want to change the name to something more descriptive.
Note: The script requires
curlandjqto be installed. Only the 30 most recent Workers are shown.
Pages Deploy Hook URL
- Go to Workers & Pages in your Cloudflare dashboard
- Select your Pages project
- Navigate to Settings > Deploy hooks section
- Add a deploy hook, provide a name, and select the branch
- Copy the full webhook URL
Usage
- Navigate to Cloudflare Deploy in the Strapi admin sidebar
- You will see all configured deployment instances
- Click Deploy on the instance you want to trigger
- Confirm the deployment in the dialog
- View the deployment result (success or error message)
