This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 332
119 lines (110 loc) · 5.57 KB
/
openwrt-G-DOCK.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
# # # # # # # # # # #
# 自动构建 openWrt G-DOCK
# 花妆男
# # # # # # # # # # #
name: OpenWrt CI G-DOCK
on:
# schedule: # 时间表
# - cron: '0 19 * * *' # 每天国际时间19点,北京时间凌晨3点执行(北京+8)
push: # push 操作
branches: # 分支
- master # 主分支
# paths: # 路径
# - openwrt/* # 监听openwrt目录下所有文件的push操作
paths: # 路径
- logs/g-dock.md # 监听logs目录下 k2.md 的push操作
# watch: # 监视操作
# types: [started] # 点击 star 之后
env:
T_NAME: "G-DOCK" # 设备名字 (op编译慢所以直接单个的编译)
BASE_PATH: openwrt # 基础目录
PUBLIC_PATH: public # 公共目录
PUBLIC_SH: public.sh # 公共执行文件
UPLOAD_PACKAGES_DIR: true # 是否导出bin文件
UPLOAD_FIRMWARE: true # 是否导出固件
CLONE_URL: https://github.com/coolsnowwolf/lede # 地址
CLONE_BRANCH: master # 分支
WORK_PATH: opt/openwrt # 工作目录
jobs:
build:
runs-on: ubuntu-18.04
if: github.event.repository.owner.id == github.event.sender.id
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checkout Master # 1.导入主分支
uses: actions/checkout@master
- name: Initialization Environment # 2.初始化环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
docker rmi `docker images -q`
sudo rm -rf /usr/share/dotnet /etc/mysql /etc/php /etc/apt/sources.list.d
sudo -E apt-get -y purge azure-cli ghc* zulu* hhvm llvm* firefox google* dotnet* powershell openjdk* mysql* php* android*
sudo -E apt-get update
sudo -E apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler antlr3 gperf swig
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf wget curl swig rsync
sudo -E apt-get -y autoremove --purge
sudo -E apt-get clean
# sudo apt-get update
# sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch python3.5 unzip zlib1g-dev lib32gcc1 libc6-dev-i386 subversion flex uglifyjs git-core gcc-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils upx libelf-dev autoconf automake libtool autopoint device-tree-compiler g++-multilib antlr3 gperf
# df -h
sudo timedatectl set-timezone 'Asia/Shanghai' # 设置时区
- name: Clone Code # 3.拷贝代码
run: |
git clone --depth=1 $CLONE_URL -b $CLONE_BRANCH $WORK_PATH
- name: Update Feeds # 4.下载Feeds
run: |
cd $WORK_PATH
./scripts/feeds update -a
- name: Load Config And Install Feeds # 5. 加载配置文件 并且安装 Feeds
run: |
[ -f $BASE_PATH/$T_NAME/banner ] && cp -f $BASE_PATH/$T_NAME/banner $WORK_PATH/package/base-files/files/etc/banner
[ -f $BASE_PATH/$T_NAME/.config ] && cp -f $BASE_PATH/$T_NAME/.config $WORK_PATH/.config
[ -f $BASE_PATH/$PUBLIC_PATH/$PUBLIC_SH ] && cp -f $BASE_PATH/$PUBLIC_PATH/$PUBLIC_SH $WORK_PATH
[ -f $BASE_PATH/$T_NAME/$T_NAME.sh ] && cp -f $BASE_PATH/$T_NAME/$T_NAME.sh $WORK_PATH
cd $WORK_PATH
echo "执行${PUBLIC_SH}"
chmod +x ./$PUBLIC_SH
sudo ./$PUBLIC_SH
if [ -f $T_NAME.sh ] ; then
echo "执行${T_NAME}sh"
chmod +x ./$T_NAME.sh
sudo ./$T_NAME.sh
fi
./scripts/feeds install -a
- name: Download Package # 6.下载包
run: |
cd $WORK_PATH
make defconfig
make download -j8
find dl -size -1024c -exec rm -f {} \;
- name: Build # 7. 构建
run: |
cd $WORK_PATH
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 V=s
- name: Organize Firmware # 8. 整理固件包
if: success()
run: |
cd $WORK_PATH/bin/targets/*/*
rm -rf packages
echo "::set-env name=FILE_NAME::$T_NAME-$(date "+%Y%m%d")" # 文件名
echo "::set-env name=FIRMWARE::$PWD" # Firmware 路径
- name: Organize Packages # 9. 整理插件包
if: success()
run: |
cd $WORK_PATH/bin/packages
echo "::set-env name=PACKAGES_PATH::$PWD" # 插件包目录文件路径
- name: Upload Packages Directory # 10. 导出插件包目录
uses: actions/upload-artifact@master
if: env.UPLOAD_PACKAGES_DIR == 'true' && success()
with:
name: OpenWrt-${{env.FILE_NAME}}-Packages
path: ${{ env.PACKAGES_PATH }}
- name: Upload Firmware Directory # 11. 导出固件目录
uses: actions/upload-artifact@master
if: success()
with:
name: OpenWrt-${{env.FILE_NAME}}
path: ${{ env.FIRMWARE }}