add clean up

This commit is contained in:
我若为王 2024-12-10 11:31:39 +08:00
parent 2e83011091
commit 1956944c76
2 changed files with 51 additions and 30 deletions

50
.github/workflows/clean-up.yml vendored Normal file
View File

@ -0,0 +1,50 @@
name: Delete old workflow runs
on:
schedule:
- cron: '0 0 * * *'
jobs:
del_runs:
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
id-token: write
steps:
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 30
keep_minimum_runs: 6
# Points to a recent commit instead of `main` to avoid supply chain attacks. (The latest tag is very old.)
- name: 🎟 Get GitHub App token
uses: actions/create-github-app-token@v1
id: get-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Delete workflow runs for current repo
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 7
keep_minimum_runs: 6
- name: Delete deployment
uses: strumwolf/delete-deployment-environment@v2.3.0
with:
token: ${{ steps.get-token.outputs.token }}
environment: Preview
onlyRemoveDeployments: true
- name: Delete MAIN deployment
uses: strumwolf/delete-deployment-environment@v2.3.0
with:
token: ${{ steps.get-token.outputs.token }}
environment: Production
onlyRemoveDeployments: true

View File

@ -24,36 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
# Points to a recent commit instead of `main` to avoid supply chain attacks. (The latest tag is very old.)
- name: 🎟 Get GitHub App token
uses: actions/create-github-app-token@v1
id: get-token
with:
app-id: ${{ secrets.GH_APP_ID }}
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}
- name: Delete workflow runs for current repo
uses: Mattraks/delete-workflow-runs@v2
with:
token: ${{ github.token }}
repository: ${{ github.repository }}
retain_days: 7
keep_minimum_runs: 6
- name: Delete deployment
uses: strumwolf/delete-deployment-environment@v2.3.0
with:
token: ${{ steps.get-token.outputs.token }}
environment: Preview
onlyRemoveDeployments: true
- name: Delete MAIN deployment
uses: strumwolf/delete-deployment-environment@v2.3.0
with:
token: ${{ steps.get-token.outputs.token }}
environment: Production
onlyRemoveDeployments: true
- name: Checkout repository
uses: actions/checkout@v2