-
Notifications
You must be signed in to change notification settings - Fork 0
/
enabler.sh
executable file
·65 lines (55 loc) · 1.17 KB
/
enabler.sh
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
60
61
62
63
64
65
#!/bin/bash
# Action Workflow Enabler CLI
# ===================================
# This script enables all CI+DEV action pipelines in the axonivy-market org.
# Using https://cli.github.com/
org="axonivy-market"
ignored_repos=(
"market-up2date-keeper"
"market.axonivy.com"
"market-monitor"
"market"
)
githubRepos() {
ghApi="orgs/${org}/repos?per_page=200"
gh api "${ghApi}"
}
githubReposC(){
cache="/tmp/gh-${org}.json"
if [ ! -f "${cache}" ]; then
githubRepos > "${cache}"
fi
cat "${cache}"
}
collectRepos() {
githubReposC |
jq -r '.[] |
select(.archived == false) |
select(.is_template == false) |
select(.default_branch == "master") |
select(.language != null) |
.name'
}
enableAll() {
echo "enabling repos actions on ${org}"
collectRepos |
while read repo_name; do
enableWfs $repo_name
done
}
workflows() {
repo=$1
wfName=$2
gh api "repos/${org}/${repo}/actions/workflows"
}
enableWfs() {
if [[ " ${ignored_repos[@]} " =~ " $1 " ]]; then
return
fi
repo=$1
where="${org}/${repo}"
echo "processing $where"
gh workflow enable -R "$where" ci.yml
gh workflow enable -R "$where" dev.yml
}
enableAll