Skip to content

Commit 985afd2

Browse files
committed
add pr cleanup workflow
1 parent d366b37 commit 985afd2

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Cleanup Dev
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
7+
jobs:
8+
cleanup-ui-pr-preview:
9+
permissions:
10+
contents: read
11+
id-token: 'write'
12+
issues: write
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Create an empty directory for cleanup
17+
run: mkdir -p empty
18+
19+
- name: Remove GitHub Pages Build
20+
uses: peaceiris/actions-gh-pages@v3
21+
with:
22+
github_token: ${{ secrets.GITHUB_TOKEN }}
23+
publish_dir: ./empty
24+
destination_dir: ui/pr/${{ github.event.pull_request.number }}
25+
keep_files: false
26+
user_name: ${{ github.actor }}
27+
user_email: ${{ github.actor }}@users.noreply.github.com
28+
publish_branch: gh-pages
29+
commit_message: 'chore: Clean up preview for PR #${{ github.event.pull_request.number }}'
30+
31+
- name: Log Cleanup Completion
32+
run: echo "Cleanup completed for PR \#${{ github.event.pull_request.number }}"
33+
34+
update-preview-comment:
35+
name: Update PR Comment
36+
permissions:
37+
pull-requests: write
38+
issues: write
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Update PR comment to reflect cleanup
42+
uses: peter-evans/create-or-update-comment@v3
43+
with:
44+
token: ${{ secrets.GITHUB_TOKEN }}
45+
issue-number: ${{ github.event.pull_request.number }}
46+
edit-mode: replace
47+
body: |
48+
<!-- pr-preview-comment -->
49+
🧹 The live preview for this PR has been removed.

.github/workflows/development.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ jobs:
250250
user_name: ${{ github.actor }}
251251
user_email: ${{ github.actor }}@users.noreply.github.com
252252
publish_branch: gh-pages
253+
commit_message: 'build: Deploy preview build for PR #${{ github.event.pull_request.number }}'
253254

254255
- name: Set deployment url
255256
id: deploy
@@ -262,5 +263,7 @@ jobs:
262263
with:
263264
token: ${{ secrets.GITHUB_TOKEN }}
264265
issue-number: ${{ github.event.pull_request.number }}
266+
edit-mode: replace
265267
body: |
268+
<!-- pr-preview-comment -->
266269
🎉 **Live Preview:** [Click here to view the live version](${{ steps.deploy.outputs.url }})

0 commit comments

Comments
 (0)