Prune Pages Deployments¶
The purpose of this command is to offer a quick way to bulk remove Cloudflare Pages deployments.
There are three ways to remove deployments:
- Deleting all deployments for a branch.
- Deleting all deployments before a certain time.
- Deleting all deployments after a certain time.
If you want to delete all deployments for a project, check out the purge deployments command.
Running¶
You need to pass the following flags to run this program:
--api-token
: Your API token with the required permissions.--account-id
: Your account ID where the pages project is located.--project
: Name of the pages project.
You need to pass only one of the following flags:
--branch
: Alias you want to remove deployments from.--before
: Date you want to remove deployments before. Format:YYYY-MM-DDTHH:mm:ss
. Example:2021-01-01T00:00:00
= January 1st, 2021 at 12:00:00 AM.--after
: Date you want to remove deployments after. Format:YYYY-MM-DDTHH:mm:ss
. Example:2021-01-01T00:00:00
= January 1st, 2021 at 12:00:00 AM.
Optional flags:
--dry-run
: See what would be deleted without actually deleting anything.--lots-of-deployments
: Useful if there are more than 1000 deployments, this will slow down the rate of listing deployments.--force
: Forces the deletes of deployments.
Example:
cloudflare-utils --api-token <API Token with Pages:Edit> --account-id <account ID> prune-deployments --project-name <project name> --branch <branch>
Warning
I have only tested this with a project with 20,000 deployments. While doing so, it was able to delete all deployments even though some throw errors. It will take a while to run with a lot of deployments so be patient.
Required API Permissions¶
- Account:Cloudflare Pages:Edit