Skip to content

Build ImmortalWrt for N1 #10

Build ImmortalWrt for N1

Build ImmortalWrt for N1 #10

name: Build ImmortalWrt for N1
on:
workflow_dispatch:
inputs:
ssh:
description: 'SSH connection to Actions'
required: false
default: 'false'
schedule:
- cron: "0 0 1 * *"
env:
REPO_URL: https://github.com/immortalwrt/immortalwrt
REPO_BRANCH: openwrt-23.05
CONFIG_FILE: N1/.config
DIY_SH: N1/diy.sh
FILES: N1/files
TZ: Asia/Shanghai
GITHUB_TOKEN: ${{ secrets.TOKEN }}
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: 准备完成
uses: actions/checkout@main
- name: 清理磁盘空间
uses: jlumbroso/free-disk-space@main
with:
tool-cache: false
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: 初始化编译环境
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update -y
sudo -E apt-get -qq install -y $(curl -fsSL https://raw.githubusercontent.com/nantayo/My-Pkg/master/2305)
sudo -E apt-get -qq autoremove --purge
sudo -E apt-get -qq clean
sudo timedatectl set-timezone "$TZ"
sudo mkdir -p /workdir
sudo chown $USER:$GROUPS /workdir
- name: 克隆源码
working-directory: /workdir
run: |
df -hT $PWD
git clone $REPO_URL -b $REPO_BRANCH --single-branch --depth=1 openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
echo "DATE=$(date "+%Y-%m-%d %H:%M:%S")" >> $GITHUB_ENV
- name: 更新 & 安装 feeds
working-directory: ./openwrt
run: |
./scripts/feeds update -a
./scripts/feeds install -a
- name: 加载自定义配置
run: |
[ -e $FILES ] && mv $FILES openwrt/files
[ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config
chmod +x $DIY_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_SH
- name: SSH 连接到 Actions
uses: P3TERX/ssh2actions@main
if: (github.event.inputs.ssh == 'true') || contains(github.event.action, 'ssh')
- name: 下载软件包
working-directory: ./openwrt
run: |
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: 编译固件
run: |
chmod -R 755 openwrt
cd openwrt
echo -e "$(nproc) thread compile"
make -j$(nproc) || make -j1 || make -j1 V=s
echo "compile_status=success" >> $GITHUB_ENV
- name: 整理磁盘空间
if: (!cancelled())
run: |
echo "清理之前:"
df -hT
mkdir openwrt-armvirt
mkdir /workdir/upload
cp openwrt/bin/targets/*/*/*.tar.gz /workdir/upload/
mv openwrt/bin/targets/*/*/*.tar.gz openwrt-armvirt/
echo -e "\n"
echo "列出空间占用前10的目录或文件:"
sudo du -h --max-depth=1 /workdir |sort -nr | head -10
rm -rf /workdir/openwrt/
echo -e "\n"
echo "清理之后:"
df -hT
echo -e "\n"
echo "/workdir路径文件"
ls -l
echo -e "\n"
echo "列出空间占用前10的目录或文件:"
sudo du -h --max-depth=1 /workdir |sort -nr | head -10
- name: 打包内核
uses: unifreq/openwrt_packit@master
env:
WHOAMI: ham
# OPENWRT_VER: R23.7.7
OPENWRT_ARMVIRT: openwrt-armvirt/*.tar.gz
PACKAGE_SOC: s905d
KERNEL_AUTO_LATEST: true
# KERNEL_REPO_URL: https://github.com/ham0223/OpenWRT-N1/tree/main/opt
KERNEL_VERSION_NAME: 5.4._6.1.
GH_TOKEN: ${{ secrets.GH_TOKEN }}
- name: 整理文件
run: mv /opt/openwrt_packit/output/* /workdir/upload/
- name: 发布固件
uses: ncipollo/release-action@v1
with:
name: OpenWrt-N1 → ${{ env.DATE }}
tag: N1-2305_${{ env.tag_name }}
artifacts: /workdir/upload/*
allowUpdates: true
token: ${{ secrets.GITHUB_TOKEN }}
body: |
🍁 注意事项:首次使用建议全新刷写
💻 适用机型: 斐讯N1
📂 源码: ${{ env.REPO_URL }}
🌳 分支: ${{ env.REPO_BRANCH }}
🌐 管理地址: 192.168.123.2
👤 用户名: root
🔒 密码: password
- name: 清理Actions空间
uses: Mattraks/delete-workflow-runs@main
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
keep_minimum_runs: 0
retain_days: 15