Skip to content

Latest commit

 

History

History
87 lines (69 loc) · 3.09 KB

File metadata and controls

87 lines (69 loc) · 3.09 KB

andykenward/github-actions-cloudflare-pages/delete

Delete deployments made using andykenward/github-actions-cloudflare-pages for the current branch or pull request.

The action is only able to delete deployments & comments that are created by andykenward/github-actions-cloudflare-pages, as it requires a certain payload in a GitHub deployment.

On closing the pull request, all the deployments for that pull request will be deleted from Cloudflare Pages, GitHub Deployment and related comments.

  • Delete Cloudflare Pages deployment.
  • Update GitHub deployment status to INACTIVE on successfully deleting the Cloudflare Pages deployment.
  • Delete GitHub deployment and related comment.
  • Output job summary of deletion.

Upgrading

If you have previous deployments using an older version of this GitHub Action please see the CHANGELOG.md for breaking changes.

Permissions

The permissions required for this GitHub Action when using the created GITHUB_TOKEN by the workflow for the github-token field.

permissions:
  actions: read # Only required for a private GitHub Repo.
  contents: read
  deployments: write
  pull-requests: write

Inputs

cloudflare-api-token:
  description: 'Cloudflare API Token.'
  required: true
github-token:
  description: 'Github API key, make sure to add the required permissions for this action.'
  required: true
github-environment:
  description: 'GitHub environment to delete deployments from. Leave undefined to delete all deployments referencing the current branch or pull_request.'
  required: false
keep-latest:
  description: 'How many deployments to keep. Default is 0.'
  default: '0'
  required: false

Examples

See GitHub Workflow example below or .github/workflow-templates/delete.yml

pull_request closed

# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: 'Deployment Deletion'
on:
  pull_request:
    types:
      - closed
    branches:
      - main

jobs:
  deploy-delete:
    permissions:
      actions: read # Only required for private GitHub Repo
      contents: read
      deployments: write
      pull-requests: write
    runs-on: ubuntu-latest
    timeout-minutes: 5
    steps:
      - name: Deploy deletion Cloudflare Pages
        uses: andykenward/github-actions-cloudflare-pages/[email protected]
        with:
          cloudflare-api-token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          github-token: ${{ secrets.GITHUB_TOKEN }}