Skip to main content

triggers

Creates, updates, deletes, gets or lists a triggers resource.

Overview

Nametriggers
TypeResource
Idcloudflare.workers.triggers

Fields

The following fields are returned by SELECT queries:

Triggers retrieved successfully

NameDatatypeDescription
external_script_idstringSystem-generated worker script tag. (example: dd7160bb9cef458093557736f4b9e75b)
build_token_namestring (example: My Build Token)
trigger_namestring (example: Production Deploy)
branch_excludesarray
branch_includesarray
build_caching_enabledboolean
build_commandstring (example: npm run build)
build_token_uuidstring (uuid)Build token UUID.
created_onstring (date-time)
deleted_onstring (date-time)
deploy_commandstring (example: npx wrangler deploy)
modified_onstring (date-time)
path_excludesarray
path_includesarray
repo_connectionobject
root_directorystringRoot directory path. (example: /)
trigger_uuidstring (uuid)Trigger UUID.

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
listselectaccount_id, external_script_idGet all triggers for a specific worker script
create_triggerinsertaccount_id, external_script_id, build_token_uuid, trigger_name, build_command, deploy_command, root_directory, branch_includes, branch_excludes, path_includes, path_excludes, repo_connection_uuidCreate a new CI/CD trigger
update_triggerupdateaccount_id, trigger_uuidUpdate an existing CI/CD trigger
delete_triggerdeleteaccount_id, trigger_uuidRemove a CI/CD trigger
purge_build_cacheexecaccount_id, trigger_uuidClear the build cache for a specific trigger

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
account_idstringThe Cloudflare account ID.
external_script_idstring
trigger_uuidstring (uuid)

SELECT examples

Get all triggers for a specific worker script

SELECT
external_script_id,
build_token_name,
trigger_name,
branch_excludes,
branch_includes,
build_caching_enabled,
build_command,
build_token_uuid,
created_on,
deleted_on,
deploy_command,
modified_on,
path_excludes,
path_includes,
repo_connection,
root_directory,
trigger_uuid
FROM cloudflare.workers.triggers
WHERE account_id = '{{ account_id }}' -- required
AND external_script_id = '{{ external_script_id }}' -- required
;

INSERT examples

Create a new CI/CD trigger

INSERT INTO cloudflare.workers.triggers (
branch_excludes,
branch_includes,
build_caching_enabled,
build_command,
build_token_uuid,
deploy_command,
external_script_id,
path_excludes,
path_includes,
repo_connection_uuid,
root_directory,
trigger_name,
account_id
)
SELECT
'{{ branch_excludes }}' /* required */,
'{{ branch_includes }}' /* required */,
{{ build_caching_enabled }},
'{{ build_command }}' /* required */,
'{{ build_token_uuid }}' /* required */,
'{{ deploy_command }}' /* required */,
'{{ external_script_id }}' /* required */,
'{{ path_excludes }}' /* required */,
'{{ path_includes }}' /* required */,
'{{ repo_connection_uuid }}' /* required */,
'{{ root_directory }}' /* required */,
'{{ trigger_name }}' /* required */,
'{{ account_id }}'
RETURNING
errors,
messages,
result,
result_info,
success
;

UPDATE examples

Update an existing CI/CD trigger

UPDATE cloudflare.workers.triggers
SET
branch_excludes = '{{ branch_excludes }}',
branch_includes = '{{ branch_includes }}',
build_caching_enabled = {{ build_caching_enabled }},
build_command = '{{ build_command }}',
build_token_uuid = '{{ build_token_uuid }}',
deploy_command = '{{ deploy_command }}',
path_excludes = '{{ path_excludes }}',
path_includes = '{{ path_includes }}',
root_directory = '{{ root_directory }}',
trigger_name = '{{ trigger_name }}'
WHERE
account_id = '{{ account_id }}' --required
AND trigger_uuid = '{{ trigger_uuid }}' --required
RETURNING
errors,
messages,
result,
result_info,
success;

DELETE examples

Remove a CI/CD trigger

DELETE FROM cloudflare.workers.triggers
WHERE account_id = '{{ account_id }}' --required
AND trigger_uuid = '{{ trigger_uuid }}' --required
;

Lifecycle Methods

Clear the build cache for a specific trigger

EXEC cloudflare.workers.triggers.purge_build_cache
@account_id='{{ account_id }}' --required,
@trigger_uuid='{{ trigger_uuid }}' --required
;