forked from tete1030/openwrt-fastbuild-actions
-
Notifications
You must be signed in to change notification settings - Fork 10
277 lines (241 loc) · 9.63 KB
/
build-openwrt.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
#=================================================
# https://github.com/tete1030/openwrt-fastbuild-actions
# Description: FAST building OpenWrt with Github Actions and Docker!
# Lisence: MIT
# Author: Texot
#=================================================
env:
# DO NOT CHANGE the following here, set them only in forked repo's Settings->Secrets page
# You don't need to set docker_registry if you are using the default Docker Hub Settings->Secrets
DK_REGISTRY: ${{secrets.docker_registry}}
DK_USERNAME: ${{secrets.docker_username}}
DK_PASSWORD: ${{secrets.docker_password}}
SLACK_WEBHOOK_URL: ${{secrets.SLACK_WEBHOOK_URL}}
TMATE_ENCRYPT_PASSWORD: ${{secrets.TMATE_ENCRYPT_PASSWORD}}
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
OPT_UPDATE_FEEDS: 1
# OPT_REBUILD: 1
name: Build OpenWrt
on:
deployment:
repository_dispatch:
workflow_dispatch:
env:
OPT_DEBUG: 1
pull_request:
push:
paths:
- 'user/**'
# # For 'schedule', see examples in: https://crontab.guru/examples.html
# # e.g. every sunday midnight: '0 0 * * 0' every midnight: '0 0 * * *'
# schedule:
# - cron: '0 0 * * 0'
# watch:
# types: [started]
jobs:
build:
runs-on: ubuntu-22.04
# For `github.event`'s structure, see: https://developer.github.com/v3/activity/events/types/
# Do not modify the trigger methods here, customize them in the `on` section
if: |
github.event_name == 'push'
|| github.event_name == 'pull_request'
|| github.event_name == 'repository_dispatch'
|| github.event_name == 'workflow_dispatch'
|| github.event_name == 'deployment'
|| (github.event_name == 'watch' && github.event.action == 'started' && github.event.repository.owner.id == github.event.sender.id)
|| github.event_name == 'schedule'
name: ${{matrix.title}} ${{matrix.target}}
strategy:
fail-fast: false
matrix:
mode:
- normal
- test
# ########### Add your target name below ###########
# E.g. target: [x86_64, wdr4310v1]
target:
# - 19.07.7
# - 19.07.8
# - 19.07.10
# - 21.02.0
# - 21.02.1
# - 21.02.2
# - 21.02.3
# - 21.02.5
# - 21.02.6
# - 21.02.7
# - 21.02.1-ha
# - 22.03.0
# - 22.03.2
# - 22.03.3
# - 22.03.4
# - 22.03.5
- 22.03.6
# - 23.05.0
# - 23.05.2
# - 23.05.3
- 23.05.4
# - snapshot
include:
- mode: normal
title: Build
- mode: test
title: Fast check
env:
HOST_WORK_DIR: ${{github.workspace}}
BUILD_MODE: ${{matrix.mode}}
BUILD_TARGET: ${{matrix.target}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Init build env
run: scripts/cisteps/build-openwrt/01-init_env.sh
- name: Check if skip this job
run: scripts/cisteps/build-openwrt/02-check_target.sh
- name: Clean up for extra space
if: env.SKIP_TARGET == '0' && env.TEST != '1'
run: scripts/cisteps/build-openwrt/03-clean_up.sh
# https://github.com/docker/setup-qemu-action
- name: Set up QEMU
id: buildx-qemu
if: env.SKIP_TARGET == '0'
uses: docker/setup-qemu-action@v3
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
id: buildx
if: env.SKIP_TARGET == '0'
uses: docker/setup-buildx-action@v3
- name: Configure docker
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/04-configure_docker.sh
- name: Check status of builders
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/05-check_builders.sh
- name: '[Debug] Wait for SSH connection (timeout 5min)'
if: env.SKIP_TARGET == '0' && env.OPT_DEBUG == '1' && env.TEST != '1'
env:
TIMEOUT_MIN: 5
uses: openlumi/safe-debugger-action@dev
- name: 'Get key-build'
run: 'echo "$OPENWRT_BUILD_KEY" > $HOST_WORK_DIR/key-build;echo "$OPENWRT_BUILD_KEY_PUB" > $HOST_WORK_DIR/key-build.pub'
if: env.SKIP_TARGET == '0' && env.TEST != '1'
shell: bash
env:
HOST_WORK_DIR: ${{github.workspace}}
OPENWRT_BUILD_KEY: ${{secrets.OPENWRT_BUILD_KEY}}
OPENWRT_BUILD_KEY_PUB: ${{secrets.OPENWRT_BUILD_KEY_PUB}}
- name: Get builder
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/06-get_builder.sh
- name: Clone/update OpenWrt
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/07-download_openwrt.sh
- name: Apply customizations
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/08-customize.sh
# Allow intermediate customization
- name: '[Debug/Menuconfig] Wait for SSH connection (timeout 30min)'
if: env.SKIP_TARGET == '0' && env.OPT_DEBUG == '1' && env.TEST != '1'
env:
TMATE_DOCKER_CONTAINER: ${{env.BUILDER_CONTAINER_ID}}
uses: openlumi/safe-debugger-action@dev
- name: Prepare config file
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/09-prepare_config.sh
- name: Download packages
if: env.SKIP_TARGET == '0'
run: scripts/cisteps/build-openwrt/10-download_packages.sh
- name: Print disk space
if: env.SKIP_TARGET == '0'
run: df -h
- name: Compile firmware and packages with multiple threads
id: mtcompile
if: env.SKIP_TARGET == '0'
continue-on-error: true
run: scripts/cisteps/build-openwrt/11-compile_multi.sh
- name: Compile firmware and packages with single threads when failed
id: stcompile
if: env.SKIP_TARGET == '0' && steps.mtcompile.outputs.started == '1' && steps.mtcompile.outputs.status != 'success'
run: scripts/cisteps/build-openwrt/12-compile_single.sh
- name: Print disk space
if: env.SKIP_TARGET == '0'
run: df -h
# failure checking
- name: '[Failure/Debug] Wait for SSH connection (timeout 30min)'
if: |
env.SKIP_TARGET == '0' && !cancelled()
&& (job.status == 'failure' || (env.OPT_DEBUG == '1' && env.TEST != '1'))
env:
TMATE_DOCKER_CONTAINER: ${{env.BUILDER_CONTAINER_ID}}
uses: openlumi/safe-debugger-action@dev
# - name: Upload bin directory
# uses: actions/upload-artifact@master
# if: env.SKIP_TARGET == '0' && !cancelled()
# with:
# name: OpenWrt_bin_${{env.BUILD_TARGET}}
# path: ${{env.HOST_BIN_DIR}}
- name: Organize files
id: organize
if: env.SKIP_TARGET == '0' && !cancelled() && ( steps.mtcompile.outputs.status == 'success' || steps.stcompile.outputs.status == 'success' )
run: scripts/cisteps/build-openwrt/14-organize_files.sh
- name: Upload firmware
uses: actions/upload-artifact@master
if: env.SKIP_TARGET == '0' && env.TEST != '1' && env.OPT_PACKAGE_ONLY != '1' && steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware_${{env.BUILD_TARGET}}
path: openwrt_firmware
- name: Upload packages
uses: actions/upload-artifact@master
if: env.SKIP_TARGET == '0' && env.TEST != '1' && steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_packages_${{env.BUILD_TARGET}}
path: ${{env.HOST_BIN_DIR}}
- name: Checkout tools repo
uses: actions/checkout@v4
if: env.SKIP_TARGET == '0' && env.TEST != '1' && steps.organize.outputs.status == 'success' && !cancelled() && github.ref == 'refs/heads/master'
with:
repository: openlumi/releases
path: ${{ env.HOST_WORK_DIR }}/releases
ref: gh-pages
token: ${{ secrets.GH_TOKEN }}
- name: Copy files into Git branch
if: env.SKIP_TARGET == '0' && env.TEST != '1' && steps.organize.outputs.status == 'success' && !cancelled() && github.ref == 'refs/heads/master'
run: |
mkdir -p ${{env.HOST_WORK_DIR}}/releases/${{env.BUILD_TARGET}}
cp -r ${{env.HOST_BIN_DIR}}/* ${{env.HOST_WORK_DIR}}/releases/${{env.BUILD_TARGET}}
scripts/make-index-html.sh ${{env.HOST_WORK_DIR}}/releases || true
- name: Commit files
if: env.SKIP_TARGET == '0' && env.TEST != '1' && steps.organize.outputs.status == 'success' && !cancelled() && github.ref == 'refs/heads/master'
run: |
cd ${{ env.HOST_WORK_DIR }}/releases
git status
git add -A
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Updates files from build ${{env.BUILD_TARGET}}" -m "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID" -a
git push
# - name: Create Pull Request
# if: env.SKIP_TARGET == '0' && env.TEST != '1' && steps.organize.outputs.status == 'success' && !cancelled()
# uses: peter-evans/create-pull-request@v3
# with:
# token: ${{ secrets.GH_TOKEN }}
# path: ${{ env.HOST_WORK_DIR }}/releases
# branch: pr-pages
# base: gh-pages
# title: 'Updates files from latest Actions build'
- name: Upload builder
if: |
env.SKIP_TARGET == '0' && !cancelled() && (
job.status == 'success'
|| env.OPT_PUSH_WHEN_FAIL == '1'
) && github.ref == 'refs/heads/master'
run: scripts/cisteps/build-openwrt/13-upload_builder.sh
# failure checking
- name: '[Failure/Debug] wait for SSH connection (timeout 30min. You are safe to cancel the job now.)'
if: |
env.SKIP_TARGET == '0' && !cancelled()
&& (job.status == 'failure' || (env.OPT_DEBUG == '1' && env.TEST != '1'))
uses: openlumi/safe-debugger-action@dev