X-OpenWrt/.github/workflows/AutoBuild.yml

134 lines
3.4 KiB
YAML
Raw Normal View History

2020-09-11 02:08:22 +00:00
#=======================================================
2020-09-08 03:23:08 +00:00
# Description: Build OpenWrt using GitHub Actions
2020-10-16 15:40:23 +00:00
# https://github.com/Hyy2001X/AutoBuild-Actions
2020-09-08 03:23:08 +00:00
# Lisence: MIT
2020-09-11 01:34:26 +00:00
# Author: P3TERX
2020-09-25 15:56:45 +00:00
# Modify: Hyy2001X
2020-09-11 02:08:22 +00:00
#=======================================================
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
name: AutoBuild OpenWrt
2020-09-08 03:23:08 +00:00
on:
2020-09-11 01:34:26 +00:00
# release:
# types: [published]
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
# push:
2020-09-25 15:56:45 +00:00
# branches:
2020-09-11 01:34:26 +00:00
# - main
2020-09-25 15:56:45 +00:00
# paths:
# - '.config'
2020-09-08 03:23:08 +00:00
2020-09-11 01:34:26 +00:00
# schedule:
# - cron: 0 8 * * 5
2020-09-08 03:23:08 +00:00
watch:
types: [started]
env:
REPO_URL: https://github.com/coolsnowwolf/lede
2020-09-11 01:58:40 +00:00
REPO_BRANCH: master
2020-09-08 03:23:08 +00:00
CONFIG_FILE: .config
2020-09-16 15:18:30 +00:00
CUSTOM_SCRIPT: ./Scripts/diy-script.sh
2020-09-11 01:34:26 +00:00
TZ: Asia/Shanghai
2020-09-19 07:37:55 +00:00
UPLOAD_RELEASE: true
2020-09-20 10:02:01 +00:00
UPLOAD_FIRMWARE: true
UPLOAD_BIN_DIR: false
2020-09-08 03:23:08 +00:00
jobs:
build:
2020-09-11 01:34:26 +00:00
runs-on: ubuntu-18.04
2020-09-08 03:23:08 +00:00
steps:
- name: Checkout
2020-09-11 01:34:26 +00:00
uses: actions/checkout@main
2020-09-08 03:23:08 +00:00
2020-09-19 07:37:55 +00:00
- name: Initialization Environment
2020-09-08 03:23:08 +00:00
env:
DEBIAN_FRONTEND: noninteractive
run: |
2020-09-27 04:43:20 +00:00
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
2020-09-25 15:56:45 +00:00
sudo -E apt-get -qq update
2020-10-16 15:40:23 +00:00
sudo -E apt-get -qq install $(curl -fsSL git.io/depends-ubuntu-1804)
2020-10-16 16:10:21 +00:00
sudo -E apt-get -qq clean
2020-09-27 04:43:20 +00:00
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
2020-09-08 03:23:08 +00:00
2020-09-19 07:37:55 +00:00
- name: Clone Openwrt source code
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:34:26 +00:00
git clone -b $REPO_BRANCH $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
2020-09-11 01:37:13 +00:00
2020-10-16 15:40:23 +00:00
- name: Run Diy-Part1 Scripts
2020-09-11 01:34:26 +00:00
run: |
2020-09-16 15:18:30 +00:00
chmod +x $CUSTOM_SCRIPT
2020-09-11 01:34:26 +00:00
cd openwrt
2020-09-19 08:24:34 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy-Part1
2020-09-11 01:37:13 +00:00
2020-09-11 01:34:26 +00:00
- name: Update & Install Feeds
2020-09-08 03:23:08 +00:00
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
2020-10-16 15:40:23 +00:00
- name: Run Diy-Part2 Scripts
2020-09-08 03:23:08 +00:00
run: |
2020-09-19 08:24:34 +00:00
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
2020-09-08 03:23:08 +00:00
cd openwrt
2020-10-16 15:40:23 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy-Part2
2020-09-11 01:37:13 +00:00
2020-10-16 15:40:23 +00:00
- name: Download Packages
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:53:27 +00:00
cd openwrt
2020-09-19 07:37:55 +00:00
make defconfig
2020-10-16 15:40:23 +00:00
make download -j8
2020-09-08 03:23:08 +00:00
find dl -size -1024c -exec rm -f {} \;
2020-10-16 15:40:23 +00:00
- name: Compile the Openwrt
2020-09-08 03:23:08 +00:00
run: |
2020-09-11 01:53:27 +00:00
cd openwrt
2020-10-16 15:40:23 +00:00
make -j$(nproc) || make -j1 || make -j1 V=s
2020-09-08 03:23:08 +00:00
2020-10-16 15:40:23 +00:00
- name: Run Diy-Part3 Scripts
2020-09-11 01:34:26 +00:00
run: |
cd openwrt
2020-10-16 15:40:23 +00:00
source $GITHUB_WORKSPACE/$CUSTOM_SCRIPT && Diy-Part3
2020-09-11 01:34:26 +00:00
2020-09-19 07:37:55 +00:00
- name: Upload Firmware to Artifacts
2020-09-11 01:34:26 +00:00
uses: actions/upload-artifact@main
2020-09-20 10:02:01 +00:00
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
2020-09-08 03:23:08 +00:00
with:
2020-09-20 10:02:01 +00:00
name: OpenWrt_Firmware
2020-09-11 01:34:26 +00:00
path: openwrt/bin/Firmware
2020-09-20 10:02:01 +00:00
2020-10-16 15:40:23 +00:00
- name: Upload Firmware directory to Artifacts
2020-09-20 10:02:01 +00:00
uses: actions/upload-artifact@main
if: env.UPLOAD_BIN_DIR == 'true' && !cancelled()
with:
2020-10-16 15:40:23 +00:00
name: OpenWrt_bin
2020-09-20 10:02:01 +00:00
path: openwrt/bin
2020-09-19 07:37:55 +00:00
- name: Generate Tag
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
2020-09-27 04:38:53 +00:00
echo "$(date +"%Y%m%d")-AutoUpdate" > update_log.txt
2020-09-19 07:37:55 +00:00
echo "::set-env name=FIRMWARE::openwrt/bin/Firmware"
echo "::set-output name=status::success"
2020-10-16 15:40:23 +00:00
- name: Upload Firmware to Releases
2020-09-19 07:37:55 +00:00
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: AutoUpdate
body_path: update_log.txt
files: ${{ env.FIRMWARE }}/*
2020-09-25 15:56:45 +00:00
2020-10-16 15:40:23 +00:00
- name: Remove old Artifacts
2020-09-25 15:56:45 +00:00
uses: c-hive/gha-remove-artifacts@v1
with:
2020-09-27 04:38:53 +00:00
age: '1 month'
2020-09-25 15:56:45 +00:00
skip-recent: 3