Skip to content

Commit

Permalink
Update cleanup action
Browse files Browse the repository at this point in the history
  • Loading branch information
devmotion committed Mar 10, 2024
1 parent 4eafce8 commit 098e636
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/DocsPreviewCleanup.yml
Expand Up @@ -4,23 +4,30 @@ on:
pull_request:
types: [closed]

# Ensure that only one "DocsPreviewCleanup" workflow is force pushing at a time
concurrency:
group: docs-preview-cleanup
cancel-in-progress: false

jobs:
cleanup:
docs-preview-cleanup:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v2
with:
ref: gh-pages
- name: Delete preview and history + push changes
run: |
if [ -d "previews/PR$PRNUM" ]; then
if [ -d "${preview_dir}" ]; then
git config user.name "Documenter.jl"
git config user.email "documenter@juliadocs.github.io"
git rm -rf "previews/PR$PRNUM"
git rm -rf "${preview_dir}"
git commit -m "delete preview"
git branch gh-pages-new $(echo "delete history" | git commit-tree HEAD^{tree})
git push --force origin gh-pages-new:gh-pages
fi
fi
env:
PRNUM: ${{ github.event.number }}
preview_dir: previews/PR${{ github.event.number }}

0 comments on commit 098e636

Please sign in to comment.