Skip to content

Commit e124383

Browse files
authored
Create documentation-cleanup.yml
1 parent e49a48c commit e124383

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
name: Documentation Cleanup
3+
4+
on:
5+
pull_request:
6+
types:
7+
- closed
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
cleanup-preview:
15+
name: Documentation preview cleanup
16+
runs-on: self-hosted
17+
steps:
18+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
19+
name: Checkout
20+
with:
21+
fetch-depth: 0
22+
ref: gh-pages
23+
# Ensure an SSH agent is running so the modified Git history can be
24+
# pushed back to GitHub
25+
- uses: webfactory/[email protected]
26+
with:
27+
ssh-private-key: ${{ secrets.JULIASIM_REGISTRY_SSH_KEY }}
28+
- name: Download `git-filter-repo`
29+
run: curl -O https://raw.githubusercontent.com/newren/git-filter-repo/v2.38.0/git-filter-repo
30+
- name: Perform cleanup
31+
run: |
32+
# Remove the actual preview deployment, but keep a record of its
33+
# deployment in the Git history
34+
#
35+
# This uses the `--force` flag as, by default, `git-filter-repo` will
36+
# _not_ work on an existing clone of a repository. It needs to be
37+
# explicitly told it is okay to rewrite the history. In this case
38+
# this should be fine, given that this code is run on CI machines so
39+
# there will always be a backup of the repository
40+
python3 git-filter-repo \
41+
--force \
42+
--invert-paths \
43+
--path=previews/PR${{ github.event.pull_request.number }} \
44+
--prune-empty=never \
45+
--refs=gh-pages
46+
- name: Push modified `gh-pages` branch
47+
run: git push "[email protected]:${GITHUB_REPOSITORY}" +HEAD:gh-pages

0 commit comments

Comments
 (0)