Add pending jobs queue endpoint and verify queue visibility (#490) #91
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: Preview Cleanup | |
| on: | |
| pull_request: | |
| types: [closed] | |
| jobs: | |
| cleanup-preview: | |
| name: Remove preview (PR #${{ github.event.pull_request.number }}) | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| deployments: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Delete Cloudflare Pages deployment | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: pages deployment delete --project-name=notify-chain-dashboard --branch=pr-${{ github.event.pull_request.number }} --yes | |
| - name: Update PR comment to mark preview removed | |
| uses: actions/github-script@v7 | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| with: | |
| script: | | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: Number(process.env.PR_NUMBER), | |
| }); | |
| const marker = '<!-- notify-chain-preview-bot -->'; | |
| const existing = comments.find(c => c.body.includes(marker)); | |
| if (!existing) return; | |
| const reason = context.payload.pull_request.merged ? 'merged' : 'closed'; | |
| const body = [ | |
| marker, | |
| '## 🚀 Preview Deployment', | |
| '', | |
| `| | |`, | |
| `|---|---|`, | |
| `| **Status** | 🗑️ Removed (PR ${reason}) |`, | |
| ].join('\n'); | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: existing.id, | |
| body, | |
| }); |