-
Notifications
You must be signed in to change notification settings - Fork 118
42 lines (36 loc) · 1.38 KB
/
pr-preview-cleanup.yml
File metadata and controls
42 lines (36 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: PR Preview Cleanup
on:
workflow_run:
workflows: ["PR Preview Cleanup Signal"]
types:
- completed
permissions:
contents: write
pull-requests: write
jobs:
cleanup:
name: Delete PR Release
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download cleanup signal
uses: actions/download-artifact@v4
with:
name: cleanup-signal
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Read PR number
id: pr
run: echo "number=$(cat number)" >> "${GITHUB_OUTPUT}"
- name: Delete PR Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_TAG: "agentapi_${{ steps.pr.outputs.number }}"
run: |
# Check if release exists and delete it
if gh release view "$RELEASE_TAG" --repo ${{ github.repository }} &>/dev/null; then
echo "Deleting release $RELEASE_TAG"
gh release delete "$RELEASE_TAG" --cleanup-tag --yes --repo ${{ github.repository }}
else
echo "Release $RELEASE_TAG does not exist, nothing to delete"
fi