X-OpenWrt/.github/workflows/d-team_newifi-d2.yml

168 lines
5.2 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
name: AutoBuild-d-team_newifi-d2
2020-09-08 03:23:08 +00:00
2021-01-11 13:44:20 +00:00
on:
repository_dispatch:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: true
default: 'false'
2020-09-08 03:23:08 +00:00
# schedule:
# - cron: 0 11 * * *
2021-01-11 13:44:20 +00:00
2021-03-10 02:20:24 +00:00
# watch:
# types: [started]
2020-09-08 03:23:08 +00:00
env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
CONFIG_FILE: d-team_newifi-d2
2021-01-05 23:38:00 +00:00
DIY_SCRIPT: Scripts/AutoBuild_DiyScript.sh
FUNCTION_SCRIPT: Scripts/AutoBuild_Function.sh
2020-09-19 07:37:55 +00:00
UPLOAD_RELEASE: true
2021-02-19 08:17:31 +00:00
UPLOAD_FIRMWARE: false
2021-02-19 08:24:31 +00:00
UPLOAD_BIN_DIR: false
2020-11-14 17:15:32 +00:00
REMOVE_OLD_RELEASE: false
2021-03-05 02:21:47 +00:00
REMOVE_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: |
echo "Deleting useless files, please wait ..."
docker rmi `docker images -q`
sudo rm -rf \
/usr/share/dotnet \
/etc/mysql \
/etc/php
sudo -E apt-get -y purge \
azure-cli \
ghc* \
zulu* \
hhvm \
llvm* \
firefox \
google* \
dotnet* \
powershell \
openjdk* \
mysql* \
php*
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 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
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
echo "Compile_Date=$(date +%Y%m%d)" > $GITHUB_WORKSPACE/Openwrt.info
echo "Display_Date=$(date +'%Y/%m/%d')" >> $GITHUB_WORKSPACE/Openwrt.info
echo "## $(date +"%Y%m%d")-$CONFIG_FILE" > update_log.txt
echo "Artifacts_DATE=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
2020-09-08 03:23:08 +00:00
- name: Clone source code
2020-09-08 03:23:08 +00:00
run: |
git clone -b $REPO_BRANCH $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
- name: Update & Install all feeds
2020-09-08 03:23:08 +00:00
run: |
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
- name: Run [Firmware-Diy] Scripts
2020-09-08 03:23:08 +00:00
run: |
chmod +x $DIY_SCRIPT
chmod +x $FUNCTION_SCRIPT
[ -f Configs/$CONFIG_FILE ] && mv Configs/$CONFIG_FILE openwrt/.config
2020-09-08 03:23:08 +00:00
cd openwrt
2021-01-05 23:38:00 +00:00
source $GITHUB_WORKSPACE/$DIY_SCRIPT
source $GITHUB_WORKSPACE/$FUNCTION_SCRIPT && Firmware-Diy_Base
Firmware-Diy
2020-09-11 01:37:13 +00:00
2021-01-11 13:44:20 +00:00
- name: SSH connection to Actions
uses: P3TERX/ssh2actions@v1.0.0
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 }}
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
./scripts/feeds update -a
./scripts/feeds install -a
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
2021-02-19 08:17:31 +00:00
make -j$(nproc) || make -j1 V=s
2020-09-08 03:23:08 +00:00
- name: Process the AutoBuild Firmware
2020-09-11 01:34:26 +00:00
run: |
cd openwrt
2021-01-05 23:38:00 +00:00
source $GITHUB_WORKSPACE/$DIY_SCRIPT
source $GITHUB_WORKSPACE/$FUNCTION_SCRIPT && PS_Firmware
2020-09-11 01:34:26 +00:00
- name: Upload AutoBuild 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
- name: Upload bin 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
- name: Upload AutoBuild Firmware to Release
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:
2021-04-04 13:44:47 +00:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2020-09-19 07:37:55 +00:00
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: Remove old Release
2020-11-14 17:15:32 +00:00
uses: dev-drprasad/delete-older-releases@v0.1.0
if: env.REMOVE_OLD_RELEASE == 'true' && !cancelled()
with:
keep_latest: 3
delete_tags: true
env:
2021-01-04 11:38:21 +00:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2021-01-05 23:38:00 +00:00
- name: Remove workflow runs
uses: GitRML/delete-workflow-runs@main
if: env.REMOVE_WORKFLOW_RUNS == 'true' && !cancelled()
with:
retain_days: 1
2021-01-11 13:44:20 +00:00
keep_minimum_runs: 3