Skip to content

Commit

Permalink
Update build-openwrt.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
zc360 committed Aug 3, 2024
1 parent 3d6ca4e commit 8b44791
Showing 1 changed file with 58 additions and 47 deletions.
105 changes: 58 additions & 47 deletions .github/workflows/build-openwrt.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
#
# Copyright (c) 2019-2020 P3TERX <https://p3terx.com>
# 版权 (c) 2019-2020 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
# 这是一个自由软件,遵循 MIT 许可证。
# 有关更多信息,请参见 /LICENSE
#
# https://github.com/P3TERX/Actions-OpenWrt
# Description: Build OpenWrt using GitHub Actions
# 描述:使用 GitHub Actions 构建 OpenWrt
#

name: Build OpenWrt
name: Build OpenWrt # 工作流名称:构建 OpenWrt

on:
repository_dispatch:
workflow_dispatch:
repository_dispatch: # 当收到 repository_dispatch 事件时触发
workflow_dispatch: # 允许手动触发工作流
inputs:
ssh:
description: 'SSH connection to Actions'
description: 'SSH 连接到 Actions'
required: false
default: 'false'

env:
REPO_URL: https://github.com/coolsnowwolf/lede
REPO_BRANCH: master
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: .config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2.sh
UPLOAD_BIN_DIR: false
UPLOAD_FIRMWARE: true
UPLOAD_COWTRANSFER: false
UPLOAD_WETRANSFER: false
UPLOAD_RELEASE: false
TZ: Asia/Shanghai
REPO_URL: https://github.com/coolsnowwolf/lede # 仓库 URL
REPO_BRANCH: master # 分支名称
FEEDS_CONF: feeds.conf.default # 自定义 feeds 配置文件
CONFIG_FILE: .config # 配置文件
DIY_P1_SH: diy-part1.sh # 自定义脚本 1
DIY_P2_SH: diy-part2.sh # 自定义脚本 2
UPLOAD_BIN_DIR: false # 是否上传 bin 目录
UPLOAD_FIRMWARE: true # 是否上传固件
UPLOAD_COWTRANSFER: false # 是否上传到 cowtransfer
UPLOAD_WETRANSFER: false # 是否上传到 WeTransfer
UPLOAD_RELEASE: false # 是否发布 release
TZ: Asia/Shanghai # 时区设置

jobs:
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-20.04 # 运行环境为 Ubuntu 20.04

steps:
- name: Check Server Performance
- name: Check Server Performance # 检查服务器性能
run: |
echo "警告⚠"
echo "分配的服务器性能有限,若选择的插件过多,务必注意CPU性能!"
Expand All @@ -53,9 +53,9 @@ jobs:
echo "--------------------------硬盘信息--------------------------"
echo "硬盘数量: $(ls /dev/sd* | grep -v [1-9] | wc -l)" && df -hT
- name: Initialization environment
- name: Initialization environment # 初始化环境
env:
DEBIAN_FRONTEND: noninteractive
DEBIAN_FRONTEND: noninteractive # 禁用交互式提示
run: |
docker rmi `docker images -q`
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /etc/mysql /etc/php
Expand All @@ -67,13 +67,13 @@ jobs:
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: Checkout
- name: Checkout # 检出代码
uses: actions/checkout@main

- name: Initialization environment
- name: Initialization environment # 初始化环境
env:
DEBIAN_FRONTEND: noninteractive
DEBIAN_FRONTEND: noninteractive # 禁用交互式提示
run: |
sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc
sudo -E apt-get -qq update
Expand All @@ -84,42 +84,53 @@ jobs:
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: Clone source code
- name: Clone source code # 克隆源代码
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Load custom feeds
- name: Load custom feeds # 加载自定义 feeds
run: |
[ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default
chmod +x $DIY_P1_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P1_SH
- name: Update feeds
- name: 添加ddms-go源码
run: |
cd openwrt
git clone https://github.com/sirpdboy/luci-app-ddns-go.git package/ddns-go
- name: 添加argon源码
run: |
cd openwrt/package/lean
rm -rf luci-theme-argon
git clone -b 18.06 https://github.com/jerrykuku/luci-theme-argon.git luci-theme-argon
- name: Update feeds # 更新 feeds
run: cd openwrt && ./scripts/feeds update -a

- name: Install feeds
- name: Install feeds # 安装 feeds
run: cd openwrt && ./scripts/feeds install -a

- name: Load custom configuration
- name: Load custom configuration # 加载自定义配置
run: |
[ -e files ] && mv files openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: SSH connection to Actions
- name: SSH connection to Actions # 连接到 Actions 的 SSH
uses: P3TERX/ssh2actions@v1.0.0
if: (github.event.inputs.ssh == 'true' && github.event.inputs.ssh != 'false') || contains(github.event.action, 'ssh')
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 }}

- name: Download package
- name: Download package # 下载包
id: package
run: |
cd openwrt
Expand All @@ -128,7 +139,7 @@ jobs:
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
- name: Compile the firmware # 编译固件
id: compile
run: |
cd openwrt
Expand All @@ -139,18 +150,18 @@ jobs:
[ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV
echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Check space usage
- name: Check space usage # 检查空间使用情况
if: (!cancelled())
run: df -hT

- name: Upload bin directory
- name: Upload bin directory # 上传 bin 目录
uses: actions/upload-artifact@main
if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'
with:
name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: openwrt/bin

- name: Organize files
- name: Organize files # 整理文件
id: organize
if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()
run: |
Expand All @@ -159,14 +170,14 @@ jobs:
echo "FIRMWARE=$PWD" >> $GITHUB_ENV
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware directory
- name: Upload firmware directory # 上传固件目录
uses: actions/upload-artifact@main
if: steps.organize.outputs.status == 'success' && !cancelled()
with:
name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}
path: ${{ env.FIRMWARE }}

- name: Upload firmware to cowtransfer
- name: Upload firmware to cowtransfer # 上传固件到 cowtransfer
id: cowtransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_COWTRANSFER == 'true' && !cancelled()
run: |
Expand All @@ -175,7 +186,7 @@ jobs:
echo "::warning file=cowtransfer.com::$(cat cowtransfer.log | grep https)"
echo "url=$(cat cowtransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Upload firmware to WeTransfer
- name: Upload firmware to WeTransfer # 上传固件到 WeTransfer
id: wetransfer
if: steps.organize.outputs.status == 'success' && env.UPLOAD_WETRANSFER == 'true' && !cancelled()
run: |
Expand All @@ -184,7 +195,7 @@ jobs:
echo "::warning file=wetransfer.com::$(cat wetransfer.log | grep https)"
echo "url=$(cat wetransfer.log | grep https | cut -f3 -d" ")" >> $GITHUB_OUTPUT
- name: Generate release tag
- name: Generate release tag # 生成发布标签
id: tag
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
run: |
Expand All @@ -194,7 +205,7 @@ jobs:
[ $UPLOAD_WETRANSFER = true ] && echo "🔗 [WeTransfer](${{ steps.wetransfer.outputs.url }})" >> release.txt
echo "status=success" >> $GITHUB_OUTPUT
- name: Upload firmware to release
- name: Upload firmware to release # 上传固件到发布
uses: softprops/action-gh-release@v1
if: steps.tag.outputs.status == 'success' && !cancelled()
env:
Expand All @@ -204,13 +215,13 @@ jobs:
body_path: release.txt
files: ${{ env.FIRMWARE }}/*

- name: Delete workflow runs
- name: Delete workflow runs # 删除工作流运行
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 1
keep_minimum_runs: 3

- name: Remove old Releases
- name: Remove old Releases # 删除旧的发布版本
uses: dev-drprasad/delete-older-releases@v0.1.0
if: env.UPLOAD_RELEASE == 'true' && !cancelled()
with:
Expand Down

0 comments on commit 8b44791

Please sign in to comment.