-
Notifications
You must be signed in to change notification settings - Fork 6
172 lines (154 loc) · 6.53 KB
/
Trigger in sequence.yml
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
name: Trigger in sequence
on:
workflow_dispatch:
schedule:
- cron: '*/20 * * * *' # 每20分钟触发一次
jobs:
trigger_adblock_reject_json:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Trigger and verify Run_Adblock_Reject_JSON.yml
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
workflow_id="Run_Adblock_Reject_JSON.yml"
ref="main"
# 触发工作流
response=$(curl -X POST -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/workflows/$workflow_id/dispatches" \
-d "{\"ref\":\"$ref\"}")
echo "Triggered workflow $workflow_id: $response"
# 验证工作流成功触发和完成
while : ; do
status=$(curl -s -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/runs?status=completed&branch=$ref" \
| jq -r '.workflow_runs[0].conclusion')
if [[ "$status" == "success" ]]; then
echo "Workflow $workflow_id completed successfully."
break
elif [[ "$status" == "failure" ]]; then
echo "Workflow $workflow_id failed."
exit 1
else
echo "Waiting for workflow $workflow_id to complete..."
sleep 30
fi
done
# 等待90秒后开始下一个工作流
echo "Waiting for 90 seconds before starting the next workflow..."
sleep 90
trigger_adblock_reject_domain_txt:
needs: trigger_adblock_reject_json
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Trigger and verify Run_Adblock_Reject_DOMAIN_TXT.yml
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
workflow_id="Run_Adblock_Reject_DOMAIN_TXT.yml"
ref="main"
# 触发工作流
response=$(curl -X POST -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/workflows/$workflow_id/dispatches" \
-d "{\"ref\":\"$ref\"}")
echo "Triggered workflow $workflow_id: $response"
# 验证工作流成功触发和完成
while : ; do
status=$(curl -s -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/runs?status=completed&branch=$ref" \
| jq -r '.workflow_runs[0].conclusion')
if [[ "$status" == "success" ]]; then
echo "Workflow $workflow_id completed successfully."
break
elif [[ "$status" == "failure" ]]; then
echo "Workflow $workflow_id failed."
exit 1
else
echo "Waiting for workflow $workflow_id to complete..."
sleep 30
fi
done
# 等待90秒后开始下一个工作流
echo "Waiting for 90 seconds before starting the next workflow..."
sleep 90
trigger_convert_ruleset_json_to_srs:
needs: trigger_adblock_reject_domain_txt
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Trigger and verify Convert_Ruleset_JSON_to_SRS.yml
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
workflow_id="Convert_Ruleset_JSON_to_SRS.yml"
ref="main"
# 触发工作流
response=$(curl -X POST -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/workflows/$workflow_id/dispatches" \
-d "{\"ref\":\"$ref\"}")
echo "Triggered workflow $workflow_id: $response"
# 验证工作流成功触发和完成
while : ; do
status=$(curl -s -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/runs?status=completed&branch=$ref" \
| jq -r '.workflow_runs[0].conclusion')
if [[ "$status" == "success" ]]; then
echo "Workflow $workflow_id completed successfully."
break
elif [[ "$status" == "failure" ]]; then
echo "Workflow $workflow_id failed."
exit 1
else
echo "Waiting for workflow $workflow_id to complete..."
sleep 30
fi
done
# 等待90秒后开始下一个工作流
echo "Waiting for 90 seconds before starting the next workflow..."
sleep 90
trigger_release_adblock_file:
needs: trigger_convert_ruleset_json_to_srs
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Trigger and verify Release_ADblock_File.yml
env:
TOKEN: ${{ secrets.TOKEN }}
run: |
workflow_id="Release_ADblock_File.yml"
ref="main"
# 触发工作流
response=$(curl -X POST -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/workflows/$workflow_id/dispatches" \
-d "{\"ref\":\"$ref\"}")
echo "Triggered workflow $workflow_id: $response"
# 验证工作流成功触发和完成
while : ; do
status=$(curl -s -H "Authorization: token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/REIJI007/AdBlock_Rule_For_Sing-box/actions/runs?status=completed&branch=$ref" \
| jq -r '.workflow_runs[0].conclusion')
if [[ "$status" == "success" ]]; then
echo "Workflow $workflow_id completed successfully."
break
elif [[ "$status" == "failure" ]]; then
echo "Workflow $workflow_id failed."
exit 1
else
echo "Waiting for workflow $workflow_id to complete..."
sleep 30
fi
done