Skip to content

Commit d987465

Browse files
committed
Add workflow for cleaning up previews on schedule
1 parent 3a72bad commit d987465

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Doc Previews Cleanup
2+
3+
on:
4+
schedule:
5+
- cron: "25 22 * * 2"
6+
workflow_dispatch:
7+
8+
concurrency:
9+
# Same group concurrency as the `Documentation.yml` workflow, because they both
10+
# git-push to the same branch, so we want to avoid clashes.
11+
group: docs-pushing
12+
13+
jobs:
14+
doc-preview-cleanup:
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: write
18+
steps:
19+
- name: Checkout gh-pages branch
20+
uses: actions/checkout@v6
21+
with:
22+
ref: gh-pages
23+
- name: Delete preview and history + push changes
24+
run: |
25+
if [[ -d previews ]]; then
26+
git config user.name "${{github.actor}}"
27+
git config user.email "${{github.actor_id}}+${{github.actor}}@users.noreply.github.com"
28+
git rm -rf previews/
29+
git commit -m 'Delete previews directory'
30+
git branch gh-pages-new $(echo "Delete history" | git commit-tree HEAD^{tree})
31+
git push --force-with-lease origin gh-pages-new:gh-pages
32+
fi

0 commit comments

Comments
 (0)