this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 46 lines 1.5 kB view raw
1name: Clean gh-pages branch 2 3on: 4 schedule: 5 - cron: "0 0 * * *" # Every day at midnight 6 workflow_dispatch: 7 8jobs: 9 clean-gh-pages: 10 runs-on: ubuntu-latest 11 permissions: 12 contents: write 13 steps: 14 - name: Checkout gh-pages branch 15 uses: actions/checkout@v6 16 with: 17 ref: gh-pages 18 - name: Install gh CLI 19 run: | 20 sudo apt-get install gh -y 21 - name: Remove dirs for PRs that are no longer open 22 env: 23 REPO_PR_URL: ${{ github.event.repository.html_url }}/pull 24 GH_TOKEN: ${{ github.token }} 25 run: | 26 open_prs=$(gh pr list --state open --json number --jq '.[].number') 27 echo Open PRs: $open_prs 28 for pr in pr-*; do 29 number=$(basename "$pr" | sed 's/^pr-//') 30 if ! echo "$open_prs" | grep -q "$number"; then 31 echo "Removing $pr, $number does not match any open PR: $REPO_PR_URL/$number" 32 rm -rf "$pr" 33 else 34 echo "Keeping $pr as $number is still open: $REPO_PR_URL/$number" 35 fi 36 done 37 38 - name: Collapse branch history and push 39 run: | 40 git config --local user.name "GitHub Actions" 41 git config --local user.email "github-actions@github.com" 42 git checkout --orphan flattened 43 git add -A 44 git commit -m "Clean up gh-pages branch" 45 git branch -M gh-pages 46 git push -f origin gh-pages