-
Notifications
You must be signed in to change notification settings - Fork 12
/
mkwk.sh
executable file
·48 lines (39 loc) · 1.05 KB
/
mkwk.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
#!/usr/bin/env bash
# 列出当前目录下的所有目录并将它们放入一个数组中
directories=($(ls -d */ | sed 's#/##'))
# 将 "alpine" 移动到数组首位
alpine_index=$(echo "${directories[@]}" | tr ' ' '\n' | grep -n "alpine" | cut -d ":" -f 1)
if [[ $alpine_index != 1 ]]; then
tmp=${directories[0]}
directories[0]=${directories[$alpine_index-1]}
directories[$alpine_index-1]=$tmp
fi
minute="0"
hour="0"
day_of_month="*"
month="*"
day_of_week="1"
for (( i=0; i<${#directories[@]}; i++ )); do
cat > .github/workflows/${directories[$i]}.yaml <<EOF
name: mritd/${directories[$i]}
on:
schedule:
- cron: $minute $hour $day_of_month $month $day_of_week
workflow_call:
workflow_dispatch:
jobs:
${directories[$i]}:
uses: ./.github/workflows/.earthly.yaml
secrets: inherit
with:
build-dir: ${directories[$i]}
EOF
hour=$((hour + 1))
if [ $hour -eq 24 ]; then
hour=0
day_of_week=$((day_of_week + 1))
if [ $day_of_week -eq 8 ]; then
day_of_week=1
fi
fi
done