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

138 lines
3.7 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-11-14 17:15:32 +00:00
# - master
2020-09-25 15:56:45 +00:00
# paths:
# - '.config'
2020-09-08 03:23:08 +00:00
2020-11-14 17:15:32 +00:00
schedule:
- cron: 0 11 * * *
2020-09-08 03:23:08 +00:00
watch:
types: [started]
env:
REPO_URL: https://github.com/coolsnowwolf/lede
CONFIG_FILE: .config
2020-11-14 17:15:32 +00:00
DIY_SCRIPT: Scripts/diy-script.sh
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-11-14 17:15:32 +00:00
REMOVE_OLD_RELEASE: false
DELETE_WORKFLOW_RUNS: true
2020-09-08 03:23:08 +00:00
jobs:
build:
2020-11-14 17:15:32 +00:00
runs-on: ubuntu-latest
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-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-11-14 17:15:32 +00:00
sudo timedatectl set-timezone "Asia/Shanghai"
2020-09-27 04:43:20 +00:00
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-11-14 17:15:32 +00:00
git clone $REPO_URL openwrt
2020-09-11 01:34:26 +00:00
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-11-14 17:15:32 +00:00
chmod +x $DIY_SCRIPT
2020-09-11 01:34:26 +00:00
cd openwrt
2020-11-14 17:15:32 +00:00
source $GITHUB_WORKSPACE/$DIY_SCRIPT && Diy-Part1
echo "Compile_Date=$(date +%Y%m%d)" > $GITHUB_WORKSPACE/Openwrt.info
echo "Display_Date=$(date +'%Y/%m/%d')" >> $GITHUB_WORKSPACE/Openwrt.info
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-11-14 17:15:32 +00:00
[ -f $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
2020-09-08 03:23:08 +00:00
cd openwrt
2020-11-14 17:15:32 +00:00
source $GITHUB_WORKSPACE/$DIY_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-21 22:53:03 +00:00
make download -j$(nproc) V=s
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-11-14 17:15:32 +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: |
2020-10-21 22:53:03 +00:00
echo "## $(date +"%Y%m%d")-AutoBuild" > update_log.txt
2020-09-11 01:34:26 +00:00
cd openwrt
2020-11-14 17:15:32 +00:00
source $GITHUB_WORKSPACE/$DIY_SCRIPT && Diy-Part3
2020-10-21 05:32:30 +00:00
echo "Artifacts_DATE=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
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-10-21 05:32:30 +00:00
name: OpenWrt_Firmware_${{ env.Artifacts_DATE }}
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-21 05:32:30 +00:00
name: OpenWrt_bin_${{ env.Artifacts_DATE }}
2020-09-20 10:02:01 +00:00
path: openwrt/bin
2020-09-19 07:37:55 +00:00
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
2020-10-21 05:32:30 +00:00
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
2020-09-19 07:37:55 +00:00
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
with:
tag_name: AutoUpdate
body_path: update_log.txt
2020-10-21 05:32:30 +00:00
files: openwrt/bin/Firmware/*
2020-11-14 17:15:32 +00:00
- name: Delete workflow runs
if: env.DELETE_WORKFLOW_RUNS == 'true' && !cancelled()
uses: ActionsRML/delete-workflow-runs@main
2020-09-25 15:56:45 +00:00
with:
2020-11-14 17:15:32 +00:00
retain_days: 1
keep_minimum_runs: 3
- name: Remove old Releases
uses: dev-drprasad/delete-older-releases@v0.1.0
if: env.REMOVE_OLD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}