Update prune workflow.

This commit is contained in:
James Cole 2023-02-23 07:03:47 +01:00
parent 6d327b98d4
commit 1033655615
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80

View File

@ -12,18 +12,18 @@ jobs:
timeout-minutes: 10
steps:
- name: Prune cancelled/skipped runs
uses: actions/github-script@v4
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
script: |
const cancelled = await github.actions.listWorkflowRunsForRepo({
const cancelled = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
per_page: 100,
repo: context.repo.repo,
status: 'cancelled',
});
const skipped = await github.actions.listWorkflowRunsForRepo({
const skipped = await github.rest.actions.listWorkflowRunsForRepo({
owner: context.repo.owner,
per_page: 100,
repo: context.repo.repo,
@ -33,7 +33,7 @@ jobs:
for (const response of [cancelled, skipped]) {
for (const run of response.data.workflow_runs) {
console.log(`Run id ${run.id} of '${run.name}' is a cancelled/skipped run. Deleting...`);
await github.actions.deleteWorkflowRun({
await github.rest.actions.deleteWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run.id
@ -42,7 +42,7 @@ jobs:
}
- name: Prune runs older than 3 days
uses: actions/github-script@v4
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_ACTIONS_PERSONAL_ACCESS_TOKEN }}
script: |
@ -67,7 +67,7 @@ jobs:
for (const workflow of workflows) {
for (let page = 0; page < pages; page += 1) {
let response = await github.actions.listWorkflowRuns({
let response = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
page: page,
per_page: 100,
@ -88,7 +88,7 @@ jobs:
for (const run of runs_to_delete) {
console.log(`Run id ${run[0]} of '${run[1]}' is older than ${days_to_expiration} days. Deleting...`);
try {
await github.actions.deleteWorkflowRun({
await github.rest.actions.deleteWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run[0]