test: de-flake cart-drawer overflow spec via consent pre-seed #54
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: pr-preview-cleanup | |
| on: | |
| pull_request: | |
| types: [closed] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: PR number to clean up | |
| required: true | |
| permissions: | |
| contents: write | |
| deployments: write | |
| pull-requests: read | |
| jobs: | |
| cleanup: | |
| runs-on: ubuntu-latest | |
| if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'workflow_dispatch' | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.pr_number }} | |
| steps: | |
| - name: Checkout gh-pages | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: gh-pages | |
| fetch-depth: 1 | |
| - name: Remove pr-${{ env.PR_NUMBER }} preview directory | |
| run: | | |
| if [ -d "pr-${PR_NUMBER}" ]; then | |
| rm -rf "pr-${PR_NUMBER}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "Nothing staged after removal — skipping commit." | |
| else | |
| git commit -m "cleanup(ui): remove pr-${PR_NUMBER} preview" | |
| git push | |
| fi | |
| else | |
| echo "No preview directory pr-${PR_NUMBER} to remove." | |
| fi | |
| - name: Mark pr-preview-${{ env.PR_NUMBER }} deployment inactive | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const envName = `pr-preview-${process.env.PR_NUMBER}`; | |
| const { data: deployments } = await github.rest.repos.listDeployments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| environment: envName, | |
| per_page: 100, | |
| }); | |
| if (deployments.length === 0) { | |
| core.info(`No deployments found for environment ${envName}`); | |
| return; | |
| } | |
| for (const dep of deployments) { | |
| await github.rest.repos.createDeploymentStatus({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| deployment_id: dep.id, | |
| state: 'inactive', | |
| description: 'PR closed; preview cleaned up.', | |
| }); | |
| } | |
| core.info(`Marked ${deployments.length} deployment(s) inactive for ${envName}.`); |