-
Notifications
You must be signed in to change notification settings - Fork 11
30 lines (27 loc) · 1.03 KB
/
PreviewCleanup.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
name: Doc Preview Cleanup
on:
pull_request:
types: [closed]
concurrency:
# Same group concurrency as the `docs.yml` workflow, because they both
# git-push to the same branch, so we want to avoid clashes.
group: docs-pushing
jobs:
doc-preview-cleanup:
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
preview_directory=previews/PR${{ github.event.number }}
if [[ -d "${preview_directory}" ]]; then
git config user.name "${{github.actor}}"
git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com"
git rm -rf "${preview_directory}"
git commit -m 'Cleanup docs for PR #${{ github.event.number }}'
git branch gh-pages-new $(echo "Delete history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi