diff --git a/.github/workflows/DocCleanup.yml b/.github/workflows/DocCleanup.yml index 612794f06..463a5f599 100644 --- a/.github/workflows/DocCleanup.yml +++ b/.github/workflows/DocCleanup.yml @@ -1,24 +1,30 @@ name: Doc Cleanup on: - push: - branches: - - gh-pages + # runs on the 1st day of every month at 03:00 UTC + schedule: + - cron: '0 3 1 * *' workflow_dispatch: +permissions: + contents: write jobs: doc-cleanup: runs-on: ubuntu-latest steps: - name: Checkout gh-pages branch - uses: actions/checkout@v4 + uses: actions/checkout@v7 with: ref: gh-pages - name: Delete old docs run: | - keep=$(readlink stable) + keep="$(readlink stable)" git config user.name "Documenter.jl" git config user.email "documenter@juliadocs.github.io" - git rm -rf v[0-9]*.[0-9]* && git checkout HEAD -- $keep - if git commit -m "keep latest docs only" ; then + git rm -rf --ignore-unmatch "v[0-9]*.[0-9]*" "previews/*" + git checkout HEAD -- "$keep" + if git diff --cached --quiet; then + echo "No old docs or previews to delete" + else + git commit -m "Delete old docs and previews" git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree}) git push --force origin gh-pages-new:gh-pages fi