-
Notifications
You must be signed in to change notification settings - Fork 38
46 lines (38 loc) · 1.32 KB
/
closePR.yml
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
# Github action to cleanup a PR preview
# Runs when a pull request is merged or comment contains '#delete_preview'
#
name: PR Preview Cleanup
on:
issue_comment:
types: [created]
pull_request:
types:
- closed
jobs:
build:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || contains(github.event.comment.body, '#delete_preview')
steps:
# Checkout existing gh-pages branch into PUBLISH_DIR
- name: Checkout gh-pages
uses: actions/checkout@v3
with:
ref: gh-pages
# Cleanup preview files
- name: PR Cleanup
run: rm -rf pr/${{github.event.issue.number}}
- name: Commit and push to gh-pages
uses: EndBug/[email protected]
with:
committer_email: [email protected]
committer_name: Fortran
message: "Sphinx build cleanup pr/${{github.event.issue.number}}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Comment on pull request
- name: Comment on pull request
uses: peter-evans/create-or-update-comment@v3
if: contains(github.event.comment.body, '#delete_preview')
with:
issue-number: ${{github.event.issue.number}}
body: The preview build for this PR has now been deleted.