Skip to content

Commit

Permalink
ci: close and clean
Browse files Browse the repository at this point in the history
Signed-off-by: thxCode <thxcode0824@gmail.com>
  • Loading branch information
thxCode committed Sep 18, 2024
1 parent cc17754 commit c081892
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/clean.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@ defaults:

on:
workflow_dispatch: { }
schedule:
- cron: "0 0 * * *" # every day at 00:00 UTC

jobs:
clean:
timeout-minutes: 5
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- name: Remove Cache
uses: actions/github-script@v7
continue-on-error: true
with:
# clean up caches,
# ref to https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries,
Expand All @@ -35,7 +37,7 @@ jobs:
repo: repo,
});
for (const c of cs.actions_caches) {
// clean closed pull request's caches.
// clean closed pull request caches.
if (c.ref.match(/^refs\/pull\/.*$/)) {
var prNum = c.ref.replace(/[^\d]/g, "")
const { data: pr } = await github.rest.pulls.get({
Expand All @@ -48,7 +50,8 @@ jobs:
}
continue
}
deleteCaches.push(c)
${{ github.event.schedule || '// clean main branch caches' }}
${{ github.event.schedule || 'deleteCaches.push(c)' }}
}
// delete
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: close

permissions:
pull-requests: write
issues: write

defaults:
run:
shell: bash

on:
workflow_dispatch: { }
schedule:
- cron: "0 0 * * *" # every day at 00:00 UTC

jobs:
close:
timeout-minutes: 5
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- name: Close Stale Issues and Pull Requests
uses: actions/stale@v9
with:
days-before-stale: 15
days-before-close: 14
exempt-issue-labels: "help wanted,good first issue,bug,bug-qa,enhancement"
stale-issue-label: "stale"
close-issue-message: "This issue was closed because it has been inactive for 14 days since being marked as stale."
exempt-pr-labels: "bug,bug-qa,enhancement"
exempt-draft-pr: true
stale-pr-label: "stale"
close-pr-message: "This pull request was closed because it has been inactive for 14 days since being marked as stale."
operations-per-run: 10000

0 comments on commit c081892

Please sign in to comment.