-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (59 loc) · 1.96 KB
/
cleanup.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: cleanup
on:
workflow_dispatch: {}
#workflow_run:
# workflows: [buildProject]
# types:
# - completed
jobs:
# This workflow prunes old workflow runs for an entire repository.
removeRun:
if: github.repository != 'n8sOrganization/project-automation'
runs-on: ubuntu-18.04
steps:
- name: Remove runs of the project configuration job
uses: actions/github-script@v4 # https://github.com/actions/github-script
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pages = 5;
let runs_to_delete = [];
for (let page = 0; page < pages; page += 1) {
let response = await github.actions.listWorkflowRuns({
owner: context.repo.owner,
page: page,
per_page: 100,
repo: context.repo.repo,
workflow_id: 'project.yaml'
});
if (response.data.workflow_runs.length > 0) {
for (const run of response.data.workflow_runs) {
runs_to_delete.push([run.id, run.name]);
}
}
}
for (const run of runs_to_delete) {
console.log(`[Deleting] Run id ${run[0]} of '${run[1]}'.`);
try {
await github.actions.deleteWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run[0]
});
} catch (error) {
// ignore errors
}
}
- name: Checkout
uses: actions/checkout@v2
- name: Remove project automation
run: |
rm ./.github/workflows/project.yaml
rm ./.github/workflows/cleanup.yaml
rm -rf ./.github/seed-issues
- name: Commit changes
uses: EndBug/add-and-commit@v7
with:
add: '.'
message: "github bot update"
signoff: true