Skip to content

chore(deps): bump the github-actions group across 1 directory with 5 updates #75

chore(deps): bump the github-actions group across 1 directory with 5 updates

chore(deps): bump the github-actions group across 1 directory with 5 updates #75

Workflow file for this run

name: Pages preview cleanup
on:
pull_request_target:
branches:
- main
types:
- closed
workflow_dispatch:
inputs:
pull_number:
description: Closed pull request whose preview alias should be retired
required: true
type: number
permissions:
contents: read
pull-requests: read
concurrency:
group: pages-cleanup-client-web-${{ github.event.pull_request.number || inputs.pull_number }}
cancel-in-progress: false
jobs:
cleanup:
name: Retire exact Pages preview
if: >-
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.base.ref == 'main' &&
github.event.pull_request.base.repo.full_name == github.repository &&
github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
timeout-minutes: 10
environment:
name: preview
url: ${{ steps.tombstone.outputs.pages-deployment-alias-url }}
steps:
- name: Resolve the closed pull request
id: identity
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
REQUESTED_PULL_NUMBER: ${{ github.event.pull_request.number || inputs.pull_number }}
with:
script: |
const pullNumber = Number(process.env.REQUESTED_PULL_NUMBER)
if (!Number.isInteger(pullNumber) || pullNumber < 1) {
core.setFailed('A positive pull-request number is required.')
return
}
const { data: pull } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullNumber,
})
if (
pull.state !== 'closed' ||
pull.base.ref !== 'main' ||
pull.base.repo.full_name !== `${context.repo.owner}/${context.repo.repo}` ||
pull.head.repo?.full_name !== `${context.repo.owner}/${context.repo.repo}`
) {
core.setFailed('Retirement only accepts a closed same-repository PR targeting main.')
return
}
core.setOutput('branch', `preview/client-web/pr-${pullNumber}`)
- name: Checkout trusted cleanup controller
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.workflow_sha }}
path: controller
persist-credentials: false
- name: Set up Node
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: controller/package.json
- name: Prepare isolated closed-preview package
run: cp -R controller/.github/pages-preview-closed .pages-preview-closed
- name: Replace the stable preview alias with a closed-page tombstone
id: tombstone
uses: cloudflare/wrangler-action@ebbaa1584979971c8614a24965b4405ff95890e0 # v4.0.0
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
packageManager: npm
wranglerVersion: 4.114.0
workingDirectory: .pages-preview-closed
command: >-
pages deploy .
--project-name=${{ vars.CLOUDFLARE_PAGES_PROJECT }}
--branch=${{ steps.identity.outputs.branch }}
--commit-hash=${{ github.workflow_sha }}
--commit-dirty=false