-
Notifications
You must be signed in to change notification settings - Fork 208
38 lines (32 loc) · 1.05 KB
/
pr_closed.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
name: PR Closed
on:
pull_request:
types:
- closed
jobs:
clean-gh-pages:
name: Clean GH Pages preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- name: Determine if cleaning is necessary
id: should-clean
run: |
if [ -d "_preview/${{ github.event.pull_request.number }}" ]; then
echo "PR preview exists, cleaning"
echo "clean=true" >> "$GITHUB_OUTPUT"
else
echo "PR preview does not exist, skipping"
echo "clean=false" >> "$GITHUB_OUTPUT"
fi
- name: Remove PR preview
run: rm -rf _preview/${{ github.event.pull_request.number }}
- name: Push cleaned branch
if: ${{ steps.should-clean.outputs.clean == 'true' }}
run: |
git config --global user.name 'PR Closed action'
git config --global user.email '[email protected]'
git commit -am 'Clean preview for PR ${{ github.event.pull_request.number }}'
git push