Merge pull request #7071 from firefly-iii/fix-prune

Update prune workflow.
This commit is contained in:
James Cole
2023-02-23 07:04:09 +01:00
committed by GitHub

View File

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