-
Notifications
You must be signed in to change notification settings - Fork 8
215 lines (188 loc) · 7 KB
/
360t7-test.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
##
#
# 感谢p3terx大神的一键编译脚本
#
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
#
#修改以下代码或者开启触发开关都好,要严格按格式对好,前面有多少空格也要看清楚
#代码里有 name: 后面的内容随便改,冒号后面是有个空格的,如果修改固件名字就要考虑能不能显示出你想要的
name: 360t7-hanwckf-test 闭源固件
#permissions: write-all
#开启写权限,防止无法上传到release
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
# schedule:
# - cron: 0 20 * * 2
# 分,时,日,月,星期。每周 三 20时执行一次 (UTC时间)
env:
REPO_URL: https://github.com/benboguan/immortalwrt-mt798x
REPO_BRANCH: test
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: config/360T7-1.config
DIY_P1_SH: script/diy-part1.sh
DIY_P2_SH: script/diy-part6.sh
SSH_ACTIONS: false
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_RELEASE: true
TZ: Asia/Shanghai
jobs:
build:
name: 编译OpenWrt-immortalwrt-mt798x固件
runs-on: ubuntu-22.04
steps:
- name: 可用磁盘空间清理 (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
swap-storage: true
- name: 准备
uses: actions/checkout@main
- name: 检查磁盘空间
run: |
echo "Free space:"
df -h
- name: 开始安装编译所需系统
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get update
sudo -E apt-get -y install build-essential gawk gcc-multilib flex git gettext libncurses5-dev libssl-dev python3-distutils zlib1g-dev
sudo -E apt-get -y autoremove
sudo -E apt-get autoclean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 下载固件源码
working-directory: /workdir
run: |
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: 加载Cache缓存
uses: klever1988/cachewrtbuild@main
with:
ccache: 'true'
mixkey: 'openwrt21.02-01'
prefix: ${{ github.workspace }}/openwrt
- name: 加载feeds跟自定义插件
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
chmod +x $DIY_P1_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P1_SH
- name: 更新 & 安装 feeds
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
- name: 加载.config设置
run: |
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
[ -d patches/feeds-package-patch ] && mv -f patches/feeds-package-patch openwrt/feeds/packages/feeds-package-patch
[ -d patches/feeds-luci-patch ] && mv -f patches/feeds-luci-patch openwrt/feeds/small/feeds-luci-patch
# [ -d patches/feeds-app-patch ] && mv -f patches/feeds-app-patch openwrt/feeds/feeds_app/feeds-app-patch
[ -d patches/luci-patch ] && mv -f patches/luci-patch openwrt/feeds/luci/luci-patch
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: SSH远程连接服务器配置固件
uses: P3TERX/[email protected]
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
env:
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
- name: 下载软件包
id: package
run: |
cd openwrt
make defconfig
make download -j8 V=11
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 编译固件
id: compile
run: |
cd openwrt
echo -e "$(($(nproc)+1)) thread compile"
make -j$(($(nproc)+1)) || make -j$(nproc) || make -j1 V=s
echo "status=success" >> $GITHUB_OUTPUT
- name: 检查github储存空间情况
if: (!cancelled())
run: df -hT
- name: 上传 bin 目录
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin
- name: 整理文件
id: organize
if: steps.compile.outputs.status == 'success'
run: |
cd openwrt/bin/targets/*/*
rm -rf *.buildinfo
rm -rf *.json
rm -rf packages
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: 上传.config配置文件在github空间
if: steps.organizer.outputs.status == 'success' && env.UPLOAD_CONFIG == 'true'
uses: actions/upload-artifact@main
with:
name: config.buildinfo_${{ env.FILE_DATE }}
path: ./config
- name: 上传固件目录
uses: actions/upload-artifact@main
if: env.UPLOAD_FIRMWARE == 'true' && steps.organize.outputs.status == 'success' && !cancelled()
with:
name: r30b1-immortalwrt-mt798x固件
path: ${{ env.FIRMWARE }}
- name: 生成release标签
id: tag
if: env.UPLOAD_RELEASE == 'true' && steps.compile.outputs.status == 'success' && !cancelled()
run: |
echo -e "✅ immortalwrt-mt798x 源码版本,256M运存建议时常重启一次,不然容易出现爆运存导致卡网" >> release.txt
echo "release_tag=$(date +"%Y.%m.%d-%H%M")-360t7-test">> $GITHUB_OUTPUT
touch release.txt
echo "360t7-test" >> release.txt
echo "📥 固件下载" >> release.txt
echo "status=success" >>$GITHUB_OUTPUT
- name: 上传固件到release
uses: softprops/action-gh-release@master
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag.outputs.release_tag }}
body_path: release.txt
files: ${{ env.FIRMWARE }}/*
- name: 删除旧发布的固件
uses: dev-drprasad/delete-older-releases@master
if: steps.compile.outputs.status == 'success' && env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 7
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 删除过时工作流程
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
retain_days: 1
keep_minimum_runs: 3