forked from 281677160/build-actions
-
Notifications
You must be signed in to change notification settings - Fork 0
executable file
·259 lines (235 loc) · 9.48 KB
/
Xwrt.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
#
# 请大家记住拉取的是我的 281677160/build-actions 仓库,拉取的是其他仓库有问题,别问我,我也不清楚什么问题
#
# 因为SSH连接配置固件直接编译,会给github停止编译的,所以要另外触发启动编译程序
#
# 一般情况下都能触发启动编译的,除非没设置好密匙,或者密匙过期了,或者密匙错误之类的
#
# REPO_TOKEN密匙制作教程:https://git.io/jm.md
#
#
name: Xwrt-源码
on:
workflow_dispatch:
inputs:
REPO_BRANCH:
description: '(Xwrt源码)请选择源码分支'
required: true
default: 'master'
type: choice
options:
- 'master'
- '21.10'
- '22.03'
- 'pr-fix-nand_do_platform_check'
- 'master-mt7981'
- 'pr-rm-ax6000'
- 'pr-wolfssl'
CONFIG_FILE:
description: '请选择配置文件'
required: true
default: 'x86_64'
type: choice
options:
- 'aarch64'
- 'x86_64'
CPU_SELECTION:
description: 'CPU优选,增加编译速度'
required: true
default: '默认'
type: choice
options:
- '默认'
- '8370C'
- '8272CL'
- '8171M'
INFORMATION_NOTICE:
description: 'Telegram或pushplus信息通知'
required: true
default: '关闭'
type: choice
options:
- '关闭'
- 'Telegram'
- 'Pushplus'
SSH_ACTION:
description: 'SSH远程配置固件'
required: false
default: 'false'
type: boolean
UPLOAD_FIRMWARE:
description: '上传固件到 Github Artifacts'
required: false
default: 'true'
type: boolean
UPLOAD_RELEASE:
description: '发布固件到 Github Releases'
required: false
default: 'false'
type: boolean
CACHEWRTBUILD_SWITCH:
description: '缓存加速编译'
required: false
default: 'true'
type: boolean
UPDATE_FIRMWARE_ONLINE:
description: '增加在线更新固件功能/自动打包Amlogic_Rockchip系列固件'
required: false
default: 'true'
type: boolean
COMPILATION_INFORMATION:
description: '是否显示编译信息'
required: false
default: 'true'
type: boolean
# 定时触发开启开始编译(把下面两个#去掉开启,时间设置请看定时开启编译说明)
# schedule:
# - cron: 35 18 * * *
env:
GITHUB_LINK: https://github.com/${{github.repository}}
GIT_ACTOR: ${{github.actor}}
GIT_REPOSITORY: ${{github.repository}}
RUN_NUMBER: ${{github.run_number}}
RUN_WORKFLOW: ${{github.workflow}}
REPO_TOKEN: ${{ secrets.REPO_TOKEN }}
PUSH_PLUS_TOKEN: ${{ secrets.PUSH_PLUS_TOKEN }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TZ: Asia/Shanghai
jobs:
build:
name: 启动"${{ matrix.target }}-${{ github.event.inputs.REPO_BRANCH }}"触发编译
runs-on: ubuntu-22.04
if: ${{ github.event.repository.owner.id }} == ${{ github.event.sender.id }}
env:
FOLDER_NAME: ${{ matrix.target }}
strategy:
fail-fast: false
matrix:
target: [Xwrt]
# 请勿对 target: [Xwrt] 做任何修改
steps:
- name: 密匙检测(密匙为空则退出)
run: |
cd ${GITHUB_WORKSPACE}
if [[ -z "${{ secrets.REPO_TOKEN }}" ]]; then
echo "您没有设置仓库密匙,请按教程设置好密匙再来"
echo "REPO_TOKEN密匙制作教程:https://git.io/jm.md"
exit 1
fi
- name: 准备结束
uses: actions/checkout@v4
- name: 检测文件和对比上游版本
run: |
cd ${GITHUB_WORKSPACE}
bash <(curl -fsSL https://raw.githubusercontent.com/281677160/common/main/custom/first.sh)
source ${GITHUB_WORKSPACE}/build/${{ env.FOLDER_NAME }}/settings.ini
export INPUTS_REPO_BRANCH="${{ github.event.inputs.REPO_BRANCH }}"
export INPUTS_CONFIG_FILE="${{ github.event.inputs.CONFIG_FILE }}"
export INPUTS_CPU_SELECTION="${{ github.event.inputs.CPU_SELECTION }}"
export INPUTS_INFORMATION_NOTICE="${{ github.event.inputs.INFORMATION_NOTICE }}"
export INPUTS_SSH_ACTION="${{ github.event.inputs.SSH_ACTION }}"
export INPUTS_UPLOAD_FIRMWARE="${{ github.event.inputs.UPLOAD_FIRMWARE }}"
export INPUTS_UPLOAD_RELEASE="${{ github.event.inputs.UPLOAD_RELEASE }}"
export INPUTS_CACHEWRTBUILD_SWITCH="${{ github.event.inputs.CACHEWRTBUILD_SWITCH }}"
export INPUTS_UPDATE_FIRMWARE_ONLINE="${{ github.event.inputs.UPDATE_FIRMWARE_ONLINE }}"
export INPUTS_COMPILATION_INFORMATION="${{ github.event.inputs.COMPILATION_INFORMATION }}"
export INPUTS_PACKAGING_FIRMWARE="${{ github.event.inputs.PACKAGING_FIRMWARE }}"
source build/${{ env.FOLDER_NAME }}/common.sh && Diy_menu1
- name: 部署编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update -y
sudo -E apt-get -qq install -y gawk git gettext libssl-dev xsltproc zip git-core wget curl grep python2.7 python3 python3-pip libpython3-dev
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /${{ env.DIY_WORK }}
sudo chown $USER:$GROUPS /${{ env.DIY_WORK }}
- name: 下载"${{ matrix.target }}-${{ github.event.inputs.REPO_BRANCH }}"源码
working-directory: /${{ env.DIY_WORK }}
run: |
git clone -b "${REPO_BRANCH}" --single-branch "${REPO_URL}" openwrt
ln -sf /${{ env.DIY_WORK }}/openwrt ${GITHUB_WORKSPACE}/openwrt
cp -Rf ${GITHUB_WORKSPACE}/build ${GITHUB_WORKSPACE}/openwrt/build
chmod -R +x ${GITHUB_WORKSPACE}/openwrt/build
- name: 公 告
if: env.REPO_TOKEN
run: |
cd ${GITHUB_WORKSPACE}
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu2
- name: 更新插件源
if: env.REPO_TOKEN
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu3
- name: 加载自定义设置
if: env.REPO_TOKEN
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu4
- name: 安装插件源
if: env.REPO_TOKEN
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu5
- name: SSH远程连接(make menuconfig)
if: env.SSH_ACTION == 'true'
uses: danshui-git/debugger-action@main
- name: 生成"${{ matrix.target }}"配置文件
if: env.REPO_TOKEN
id: compile
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_menu6
- name: 上传"${{ matrix.target }}"配置文件在 Github Artifacts
if: steps.compile.outcome == 'success'
uses: actions/upload-artifact@main
with:
name: .config_${{ env.SOURCE }}_${{ env.LUCI_EDITION }}_${{ env.TARGET_PROFILE }}_${{ env.Firmware_Date }}
path: openwrt/build_logo/config.txt
- name: 编译信息
continue-on-error: true
if: env.COMPILATION_INFORMATION == 'true'
run: |
cd openwrt
source ${BUILD_PATH}/common.sh && Diy_xinxi
- name: 清理Actions空间
continue-on-error: true
if: env.REPO_TOKEN
uses: small-5/delete-workflow-runs@main
with:
token: ${{ secrets.REPO_TOKEN }}
repository: ${{ github.repository }}
retain_min: ${{ env.RETAIN_MINUTE }}
- name: 清理releases
continue-on-error: true
if: env.REPO_TOKEN
uses: ophub/delete-releases-workflows@main
with:
delete_releases: true
releases_keep_keyword: targz/Update
releases_keep_latest: ${{ env.KEEP_LATEST }}
delete_tags: true
delete_workflows: false
workflows_keep_day: 90
gh_token: ${{ secrets.REPO_TOKEN }}
- name: 触发启动"${{ matrix.target }}"开始编译
id: gitpush
if: steps.compile.outcome == 'success' && env.REPO_TOKEN
run: |
cd ${GITHUB_WORKSPACE}
source ${BUILD_PATH}/common.sh && build_openwrt
- name: Telegram或pushplus信息通知
if: env.PUSH_PLUS_TOKEN && env.INFORMATION_NOTICE == 'PUSH' || env.TELEGRAM_BOT_TOKEN && env.INFORMATION_NOTICE == 'TG'
run: |
if [[ "${{ env.INFORMATION_NOTICE }}" == "TG" ]]; then
if [[ "${{steps.gitpush.outcome}}" == 'success' ]]; then
curl -k --data chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" --data "text=🎉 主人💕:您的编译脚本成功触发【${{matrix.target}}】文件夹编译【${REPO_BRANCH}分支的${{env.TARGET_PROFILE}}】固件中,请耐心等待...... 😋(${{env.WAREHOUSE_MAN}}仓库的#${{env.RUN_NUMBER}}号)!($(date +%Y年%m月%d号%H时%M分))💐" "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"
fi
fi
if [[ "${{ env.INFORMATION_NOTICE }}" == "PUSH" ]]; then
if [[ "${{steps.gitpush.outcome}}" == 'success' ]]; then
curl -k --data token="${{ secrets.PUSH_PLUS_TOKEN }}" --data title="开始编译【${{matrix.target}}】" --data "content=🎉 主人💕:您的编译脚本成功触发【${{matrix.target}}】文件夹编译【${REPO_BRANCH}分支的${{env.TARGET_PROFILE}}】固件中,请耐心等待...... 😋(${{env.WAREHOUSE_MAN}}仓库的#${{env.RUN_NUMBER}}号)!($(date +%Y年%m月%d号%H时%M分))💐" "http://www.pushplus.plus/send"
fi
fi