-
Notifications
You must be signed in to change notification settings - Fork 801
340 lines (289 loc) · 13 KB
/
issues.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Issues
on:
issues:
types: [opened, reopened]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Check Issues
shell: python
run: |
# -*- coding: utf-8 -*-
import json, subprocess
def set_output(name, value):
subprocess.call(["echo '{}={}' >> $GITHUB_ENV".format(name, value)], shell=True)
issuetitle = ${{ toJSON(github.event.issue.title) }};
issuebody = ${{ toJSON(github.event.issue.body) }};
iscustom = 'false'
warinfo = 'false'
format = ''
language= ''
model = ''
version = ''
kernel = ''
addons = ''
modules = ''
try:
if issuetitle.lower().startswith('custom'):
jsonbody = json.loads(issuebody)
iscustom = 'true'
format = jsonbody.get('format', '')
language = jsonbody.get('language', '')
model = jsonbody.get('model', '')
version = jsonbody.get('version', '')
kernel = jsonbody.get('kernel', '')
addons = jsonbody.get('addons', '')
modules = jsonbody.get('modules', '')
except ValueError as e:
pass
if iscustom == 'false':
if issuebody.find('DMI') < 0 and issuebody.find('CPU') < 0 and issuebody.find('NIC') < 0:
warinfo = 'true'
set_output("iscustom", iscustom)
set_output("warinfo", warinfo)
set_output("format", format)
set_output("language", language)
set_output("model", model)
set_output("version", version)
set_output("kernel", kernel)
set_output("addons", addons)
set_output("modules", modules)
- name: Update Comment Warinfo
if: env.warinfo == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: "create-comment"
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
<img src="https://user-images.githubusercontent.com/5615843/235939097-6798da58-24fd-44cc-9970-c8d2f9609704.jpg" width="400">
请填写以下信息.
Please fill in the following information.
Install ENV: (You can find it in the boot interface.)
* DMI:
* CPU:
* NIC: (pid & vid)
RR version: (You can find it in the update menu.)
* RR:
* addons:
* modules:
* lkms:
DSM:
* model:
* version:
Issue:
logs:
(## 因为 log中存在 SN/MAC 等一些敏感信息, 当提供完整文件时请自行抹除他们, 当然你也可以发送到我的邮箱. ##)
(## Because the log contains some sensitive information such as SN/MAC, please delete them when providing the complete file. Of course, you can also send it to my email. ##)
...
(请先看一下#173、#175、#226 的内容)
(Plz review the content of #173, #175, #226 first)
...
(如果你只是说 XXX 不能用, 什么详细信息也不提供, 我也只能说感谢你的反馈.)
(If you just say XXX doesn't work without providing any details, I can only say thank you for your feedback.)
...
emoji: heart
- name: Update Comment Labels
if: env.iscustom == 'true'
uses: actions-cool/issues-helper@v3
with:
actions: 'add-labels'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: 'custom,${{ env.model }}'
- name: Update Comment Building
if: env.iscustom == 'true'
id: comment
uses: actions-cool/issues-helper@v3
with:
actions: 'create-comment'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
Hi @${{ github.event.issue.user.login }}.
RR-${{ env.model }} building (Usually about 5 minutes) ...
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: heart
- name: Run Build
if: env.iscustom == 'true'
run: |
# 累了, 毁灭吧!
function writeConfigKey() {
[ "${2}" = "{}" ] && sudo yq eval '.'${1}' = {}' --inplace "${3}" 2>/dev/null || sudo yq eval '.'${1}' = "'"${2}"'"' --inplace "${3}" 2>/dev/null
}
function readConfigKey() {
RESULT=$(yq eval '.'${1}' | explode(.)' "${2}" 2>/dev/null)
[ "${RESULT}" == "null" ] && echo "" || echo "${RESULT}"
}
function mergeConfigStr() {
local JF=$(mktemp)
echo "${2}" | yq -p ${1} -o y > "${JF}"
yq eval-all --inplace '. as $item ireduce ({}; . * $item)' --inplace "${3}" "${JF}" 2>/dev/null
rm -f "${JF}"
}
REPO="${{ github.server_url }}/${{ github.repository }}"
MODEL="${{ env.model }}"
VERSION="${{ env.version }}"
PRERELEASE="true"
TAG=""
if [ "${PRERELEASE}" = "true" ]; then
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -r 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)"
else
LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")"
TAG="${LATESTURL##*/}"
fi
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}"
rm -f rr-${TAG}.img.zip
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/rr-${TAG}.img.zip" -o "rr-${TAG}.img.zip")
if [ $? -ne 0 -o ${STATUS:-0} -ne 200 ]; then
echo "Download failed"
exit 1
fi
unzip rr-${TAG}.img.zip -d "rr"
export TERM=xterm
sudo ./localbuild.sh create rr/ws rr/rr.img
if [ $? -ne 0 ]; then
echo "create failed"
exit 1
fi
# sudo cp -rf files/initrd/opt/rr/* rr/ws/initrd/opt/rr/
# sudo sed -i "s/set -e/set -ex/" rr/ws/initrd/opt/rr/init.sh
# sudo sed -i '/^alias/i\set -x' rr/ws/initrd/opt/rr/menu.sh
[ -n "${{ env.language }}" ] && echo "${{ env.language }}.UTF-8" | sudo tee rr/ws/mnt/p1/.locale
sudo ./localbuild.sh init
if [ $? -ne 0 ]; then
echo "init failed"
exit 1
fi
if [ -n "${{ env.kernel }}" ]; then
echo "set kernel"
USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml"
writeConfigKey "kernel" "${{ env.kernel }}" "${USER_CONFIG_FILE}"
fi
sudo ./localbuild.sh config "${MODEL}" "${VERSION}"
if [ $? -ne 0 ]; then
echo "config failed"
exit 1
fi
if [ -n "${{ env.addons }}" ]; then
echo "set addons: ${{ env.addons }}"
USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml"
writeConfigKey "addons" "{}" "${USER_CONFIG_FILE}"
for A in $(echo "${{ env.addons }}" | sed 's/,/ /g'); do
writeConfigKey "addons.\"${A}\"" "" "${USER_CONFIG_FILE}"
done
fi
if [ ! "custom" = "${{ env.kernel }}" ] && [ -n "${{ env.modules }}" ]; then
echo "set modules: ${{ env.modules }}"
USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml"
writeConfigKey "modules" "{}" "${USER_CONFIG_FILE}"
# L="$(for I in $(echo "${{ env.modules }}" | sed 's/,/ /g'); do echo "modules.${I}:"; done)"
# mergeConfigStr p "${L}" "${USER_CONFIG_FILE}"
for M in $(echo "${{ env.modules }}" | sed 's/,/ /g'); do
writeConfigKey "modules.\"${M}\"" "" "${USER_CONFIG_FILE}"
done
fi
sudo ./localbuild.sh build
if [ $? -ne 0 ]; then
echo "build failed"
exit 1
fi
sudo ./localbuild.sh pack rr/rr.img
if [ $? -ne 0 ]; then
echo "pack failed"
exit 1
fi
ls rr -al
RR_VERSION_FILE="rr/ws/mnt/p1/RR_VERSION"
USER_CONFIG_FILE="rr/ws/mnt/p1/user-config.yml"
echo "" > README.txt
echo "RR: " >> README.txt
echo " VERSION: $(cat ${RR_VERSION_FILE} 2>/dev/null | head -1)" >> README.txt
echo " CUSTOM: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" >> README.txt
echo "" >> README.txt
echo "DSM:" >> README.txt
echo " MODEL: $(readConfigKey "model" "${USER_CONFIG_FILE}")" >> README.txt
echo " VERSION: $(readConfigKey "productver" "${USER_CONFIG_FILE}")" >> README.txt
echo " KERNEL: $(readConfigKey "kernel" "${USER_CONFIG_FILE}")" >> README.txt
echo " PATURL: $(readConfigKey "paturl" "${USER_CONFIG_FILE}")" >> README.txt
echo " PATSUM: $(readConfigKey "patsum" "${USER_CONFIG_FILE}")" >> README.txt
echo "" >> README.txt
echo "" >> README.txt
echo "After the image is written to the disk, it will boot directly into DSM without the need to compile again." >> README.txt
echo "Of course, you can also modify the settings yourself." >> README.txt
if [ "${{ env.format }}" = "ova" ]; then
. scripts/func.sh "${{ secrets.RRORG }}"
convertova "rr/rr.img" "rr/rr.ova"
(cd rr; sha256sum rr.ova >../sha256sum)
zip -9 "rr-${MODEL}-${TAG}-${{ github.run_id }}.ova.zip" -j rr/rr.ova ${USER_CONFIG_FILE} sha256sum README.txt
elif [ "${{ env.format }}" = "vmdk" ]; then
qemu-img convert rr/rr.img -O vmdk -o 'adapter_type=lsilogic,subformat=streamOptimized,compat6' rr/rr.vmdk
(cd rr; sha256sum rr.vmdk >../sha256sum)
zip -9 "rr-${MODEL}-${TAG}-${{ github.run_id }}.vmdk.zip" -j rr/rr.vmdk ${USER_CONFIG_FILE} sha256sum README.txt
elif [ "${{ env.format }}" = "vhdx" ]; then
qemu-img convert rr/rr.img -O vhdx -o subformat=dynamic rr/rr.vhdx
(cd rr; sha256sum rr.vhdx >../sha256sum)
zip -9 "rr-${MODEL}-${TAG}-${{ github.run_id }}.vhdx.zip" -j rr/rr.vhdx ${USER_CONFIG_FILE} sha256sum README.txt
else
(cd rr; sha256sum rr.img >../sha256sum)
zip -9 "rr-${MODEL}-${TAG}-${{ github.run_id }}.img.zip" -j rr/rr.img ${USER_CONFIG_FILE} sha256sum README.txt
fi
echo "TAG=${TAG}" >> $GITHUB_ENV
- name: Upload to Artifacts
if: env.iscustom == 'true' && success()
uses: actions/upload-artifact@v4
with:
name: rr-${{ env.model }}-${{ env.TAG }}
path: |
rr-${{ env.model }}-${{ env.TAG }}*.zip
retention-days: 5
- name: Update Comment Success
if: env.iscustom == 'true' && success()
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.comment.outputs.comment-id }}
update-mode: replace
body: |
Hi @${{ github.event.issue.user.login }}.
RR-${{ env.model }} build success, please download the attachment from the below link (Attachments are only kept for 5 days).
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: hooray
- name: Close Issues
if: env.iscustom == 'true' && success()
uses: actions-cool/issues-helper@v3
with:
actions: 'close-issue'
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
- name: Update Comment Fail
if: env.iscustom == 'true' && failure()
uses: actions-cool/issues-helper@v3
with:
actions: 'update-comment'
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.comment.outputs.comment-id }}
update-mode: replace
body: |
Hi @${{ github.event.issue.user.login }}.
RR-${{ env.model }} build failed, please try again.
> ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
----
emoji: confused