Skip to content

Commit 5a4bdc0

Browse files
committed
[wf] gha_clean wf check self
1 parent 0342db4 commit 5a4bdc0

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

.github/workflows/gha_clean.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# workflow to clean github actions for my repositories
1+
# workflow to clean github workflow runs for my repositories
22

3-
name: Github Action Clean
3+
name: Github WF Runs Clean
44
on:
55
push:
66
schedule:
@@ -10,20 +10,23 @@ on:
1010
jobs:
1111
gha_clean:
1212
runs-on: ubuntu-latest
13-
name: Github Action Clean
13+
name: Github WF Runs Clean
1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Install dependencies
1717
run: |
1818
python -m pip install --upgrade pip
1919
pip install pytest
2020
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
21+
- name: check self
22+
run: |
23+
python3 ./gh_workflow_runs_delete.py -d -r grindsa/github_actions_clean -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
2124
- name: check a2c
2225
run: |
23-
python3 ./github_actions_clean.py -d -r grindsa/acme2certifier -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
26+
python3 ./gh_workflow_runs_delete.py -d -r grindsa/acme2certifier -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
2427
- name: check est_proxy
2528
run: |
26-
python3 ./github_actions_clean.py -d -r grindsa/est_proxy -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
29+
python3 ./gh_workflow_runs_delete.py -d -r grindsa/est_proxy -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
2730
- name: check dkb-robo
2831
run: |
29-
python3 ./github_actions_clean.py -d -r grindsa/dkb-robo -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2
32+
python3 ./gh_workflow_runs_delete.py -d -r grindsa/dkb-robo -t ${{ secrets.GH_TOKEN }} -u ${{ secrets.GH_USER }} -c 2

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<!-- markdownlint-disable MD013 -->
2+
# github_workflow_clean

github_actions_clean.py renamed to gh_workflow_runs_delete.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def arg_parse():
1313
""" simple argparser """
14-
parser = argparse.ArgumentParser(description='github_actions_clean.py - clean github action logs and artifacts')
14+
parser = argparse.ArgumentParser(description='gh_workflow_runs_delete.py - delete github action logs and artifacts')
1515
parser.add_argument('-d', '--debug', help='debug mode', action="store_true", default=False)
1616
parser.add_argument('-r', '--reponame', help='repositoryname', default=None)
1717
parser.add_argument('-u', '--username', help='username', default=None)
@@ -50,9 +50,9 @@ def branchlist_get(debug, auth, reponame):
5050

5151
return branch_list
5252

53-
def actionslist_get(debug, auth, reponame):
53+
def wfruns_get(debug, auth, reponame):
5454
""" get list of runs """
55-
print_debug(debug, 'actionslist_get()')
55+
print_debug(debug, 'wfruns_get()')
5656
perpage = 100
5757
url = 'https://api.github.com/repos/{0}/actions/runs?per_page={1}'.format(reponame, perpage)
5858
resp = requests.get(url=url, auth=auth)
@@ -74,9 +74,9 @@ def actionslist_get(debug, auth, reponame):
7474
# json_store('ids.json', workflow_list)
7575
return workflow_list
7676

77-
def actionlist_group(debug, action_list):
77+
def wfruns_group(debug, action_list):
7878
""" group action list by branch """
79-
print_debug(debug, 'actionlist_group()')
79+
print_debug(debug, 'wfruns_group()')
8080
actions_dic = {}
8181
for workflow in action_list:
8282
if 'head_branch' in workflow and 'head_sha' in workflow and 'head_commit' in workflow and 'id' in workflow:
@@ -145,11 +145,11 @@ def idlist_delete(debug, auth, reponame, id_list):
145145
BRANCH_LIST = branchlist_get(DEBUG, AUTH, REPONAME)
146146
# print(BRANCH_LIST)
147147
if BRANCH_LIST:
148-
ACTION_LIST = actionslist_get(DEBUG, AUTH, REPONAME)
148+
ACTION_LIST = wfruns_get(DEBUG, AUTH, REPONAME)
149149
# ACTION_LIST = json_load('foo.json')
150150

151151
# group actions per branch
152-
ACTION_DIC = actionlist_group(DEBUG, ACTION_LIST)
152+
ACTION_DIC = wfruns_group(DEBUG, ACTION_LIST)
153153

154154
# select ids to be deleted
155155
ID_LIST = idlist_filter(DEBUG, ACTION_DIC, BRANCH_LIST, COMMIT_NUMBER)

0 commit comments

Comments
 (0)