nightly orphaned runners cleanup #798
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'nightly orphaned runners cleanup' | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 1 * * *' # every night at 1 am UTC | |
jobs: | |
remove-runners: | |
runs-on: ubuntu-latest | |
steps: | |
- name: removing orphaned self-runners | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
run: | | |
gh api -H "Accept: application/vnd.github.v3+json" /repos/orb-community/pktvisor/actions/runners -q '.runners[] | {id,status,busy} | select((.busy == false) and (.status == "offline")) | {id} | .[]' --paginate | xargs -I {} gh api --method DELETE -H "Accept: application/vnd.github.v3+json" /repos/orb-community/pktvisor/actions/runners/{} | |
# - name: Clear cache | |
# uses: actions/github-script@v6 | |
# with: | |
# script: | | |
# console.log("About to clear") | |
# const caches = await github.rest.actions.getActionsCacheList({ | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# }) | |
# for (const cache of caches.data.actions_caches) { | |
# console.log(cache) | |
# github.rest.actions.deleteActionsCacheById({ | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# cache_id: cache.id, | |
# }) | |
# } | |
# console.log("Clear completed") |