[网络]薅资本主义羊毛之GitHub编译OpenWrt

上篇 发布后,大神们纷纷回复GitHub的actions可以在线编译,心疼我18元的同时,开始了快乐薅羊毛之旅。。。。

查看了资料后,actions的语法很多,功能强大。薅羊毛心切,设想是否可以让actions直接调用shell脚本,编写比较熟悉的shell脚本完成编译?

于是乎我开始了实验&测试&学习。以下我一共在版本库中增加了3个文件。

分别是

.github/workflows/blank.yml

*.yml文件可以认为actions的启动脚本。源码如下:

<code>name: Openwrt-build

on: push

jobs:
build:
runs-on: ubuntu-18.04
steps:
# 检出版本库
- name: Checkout
uses: actions/checkout@v2

# 运行脚本
- name: Run Shell Script
run: ./run.sh

# 输出文件
- name: Upload artifact
uses: actions/upload-artifact@master
with:
name: outfile
path: ./output/<code>

【解释】

  • actions/checkout@v2:功能是导出版本库;
  • run: ./run.sh:可以认为shell脚本入口;
  • actions/upload-artifact@master:功能是上传output文件夹,shell脚本输出成果物放到output文件夹中即可实现上传。

run.sh

<code>#!/bin/bash
mkdir output
./openwrt.sh output/<code>

openwrt.sh

<code>#!/bin/bash

# 更新系统
sudo apt-get update
sudo apt-get -y install tree
sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev libz-dev patch 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

# 下载openwrt源码
git clone -b openwrt-19.07 https://github.com/openwrt/openwrt.git
pushd openwrt

# 更新feed
./scripts/feeds update -a
./scripts/feeds install -a

# 配置
rm -rf .config .config.all
cat >> .config <CONFIG_TARGET_bcm53xx=y
CONFIG_TARGET_bcm53xx_DEVICE_phicomm-k3=y
CONFIG_PACKAGE_luci=y
CONFIG_PACKAGE_tcpdump=y
EOF
make defconfig

# 开始编译
make V=99
popd

# 上载文件

cp openwrt/bin/targets/bcm53xx/generic/openwrt-bcm53xx-phicomm-k3-squashfs.trx $1/
/<code>

以上脚本提交后,push到github中,github就会自动运行。经测试,openwrt编译基本上1小时40多分钟完成。

如下:可实时查看编译状态


[网络]薅资本主义羊毛之GitHub编译OpenWrt

最后,附上github路径(求小星星),github.com/kukutt/actions.git


分享到:


相關文章: