Skip to content

Commit

Permalink
ci: add garbage collection (#32)
Browse files Browse the repository at this point in the history
* chore: rename workflow

* chore: rename push.yml to release.yml

* chore: rename workflow

* chore: rename workflow

* ci: add garbage collection

* fix: syntax incorrect

* fix: syntax error

* fix: syntax error

* fix: syntax error

* ci: gc every month first day
  • Loading branch information
sky172839465 authored Jan 15, 2024
1 parent c10a0a1 commit e667f6c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/gc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: garbage collection
on:
# pull_request:
# types: [opened, reopened, synchronize]
# https://crontab.guru/#0_1_1_*_*
schedule:
- cron: "0 1 1 * *"
permissions:
actions: write
contents: write
id-token: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
garbage_collection:
name: Remove old build result on GH page
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages

- id: remove
run: |
echo "OLD_FOLDERS=$(git ls-tree -r --name-only gh-pages@{30.days.ago} | cut -d/ -f1 | uniq)"
if [ -n "$OLD_FOLDERS" ]; then
rm -r $OLD_FOLDERS
git add .
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "docs: 🤖 garbage collection old build results"
echo "result=1" >> $GITHUB_OUTPUT
else
echo "result=''" >> $GITHUB_OUTPUT
fi
- name: Push changes
uses: ad-m/github-push-action@master
if: ${{ steps.remove.outputs.OLD_FOLDERS != '' }}
with:
github_token: ${{ env.GITHUB_TOKEN }}
branch: gh-pages
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: main
name: pull request
on:
pull_request:
types: [opened, reopened, synchronize, closed]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Release"
name: "release"

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/schedule.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Schedule testing
name: schedule testing
on:
schedule:
- cron: "0 2 * * 3,6"
Expand Down

0 comments on commit e667f6c

Please sign in to comment.