Repository navigation
build(deps): bump pnpm/action-setup from 6.0.10 to 6.1.0 in the github-actions group across 1 directory #22
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pages preview cleanup | ||
|
Check warning on line 1 in .github/workflows/pages-preview-cleanup.yml
|
||
| on: | ||
| pull_request_target: | ||
| branches: | ||
| - main | ||
| types: | ||
| - closed | ||
| workflow_dispatch: | ||
| inputs: | ||
| pull_number: | ||
| description: Closed pull request whose preview should be retired | ||
| required: true | ||
| type: number | ||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
| concurrency: | ||
| group: pages-preview-docs-${{ github.event.pull_request.number || inputs.pull_number }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| cleanup: | ||
| name: Retire exact pull-request 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('Cleanup only accepts a closed same-repository pull request targeting main.') | ||
| return | ||
| } | ||
| core.setOutput('branch', `preview/docs/pr-${pullNumber}`) | ||
| - name: Checkout the 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/website/package.json | ||
| - name: Replace the closed preview with a noindex 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: controller/website/preview-closed | ||
| command: >- | ||
| pages deploy . | ||
| --project-name=${{ vars.CLOUDFLARE_PAGES_PROJECT }} | ||
| --branch=${{ steps.identity.outputs.branch }} | ||
| --commit-hash=${{ github.workflow_sha }} | ||
| --commit-dirty=false | ||