-
Notifications
You must be signed in to change notification settings - Fork 15
65 lines (58 loc) · 2.02 KB
/
Copy pathpr-cleanup.yml
File metadata and controls
65 lines (58 loc) · 2.02 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: 'CI: Docs Cleanup'
on:
pull_request_target:
types: [closed]
permissions:
pull-requests: write
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Remove Surge deployment
run: |
DEPLOY_DOMAIN=preview-${{ github.event.pull_request.number }}-tiny-robot.surge.sh
echo "Removing deployment: $DEPLOY_DOMAIN"
npx surge teardown $DEPLOY_DOMAIN --token $SURGE_TOKEN
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
continue-on-error: true
- name: Comment cleanup status
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const marker = process.env.COMMENT_MARKER;
const body = process.env.COMMENT_BODY;
const issue_number = Number(process.env.PR_NUMBER);
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number,
per_page: 100,
});
const existingComment = comments.find((comment) =>
comment.user?.login === 'github-actions[bot]' &&
comment.body?.includes(marker)
);
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body,
});
} else {
await github.rest.issues.createComment({
issue_number,
owner: context.repo.owner,
repo: context.repo.repo,
body,
});
}
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
COMMENT_MARKER: '<!-- DEPLOY_PREVIEW -->'
COMMENT_BODY: |
## 🧹 Preview Cleaned Up
The preview deployment has been removed.
<!-- DEPLOY_PREVIEW -->