Skip to content

on-update

on-update #72

Workflow file for this run

#
# https://github.com/P3TERX/Actions-OpenWrt
#
# File: .github/workflows/openwrt-bulder.yml
# Description: Build OpenWrt using GitHub Actions
#
# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: OpenWrt Router Builder
on:
workflow_dispatch:
repository_dispatch:
types: [on-update]
env:
REPO_URL: https://github.com/immortalwrt/immortalwrt
REPO_BRANCH: openwrt-23.05
VERSION: 23.05
FEEDS_CONF: feeds.conf.default
CONFIG_FILE: .config
DIY_P1_SH: diy-part1.sh
DIY_P2_SH: diy-part2-router.sh
TZ: Asia/Shanghai
jobs:
OpenWrt_Router_Builder:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@main
- name: Check space usage
if: (!cancelled())
run: df -hT
- name: Free disk space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Check space usage
if: (!cancelled())
run: df -hT
- name: Initialization environment
env:
DEBIAN_FRONTEND: noninteractive
run: |
sudo -E apt-get -qq update
sudo bash -c 'bash <(curl -s https://build-scripts.immortalwrt.org/init_build_environment.sh)'
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: Clone source code
working-directory: /workdir
run: |
df -hT $PWD
git clone -b $REPO_BRANCH --single-branch --depth 1 $REPO_URL openwrt
ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt
- name: Load custom 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
run: cd openwrt && ./scripts/feeds update -a
- name: Install feeds
run: cd openwrt && ./scripts/feeds install -a
- name: Generate default configuration
run: cd openwrt && make defconfig
- name: Load custom configuration
run: |
chmod +x $DIY_P2_SH
cd openwrt
$GITHUB_WORKSPACE/$DIY_P2_SH
- name: Download package
id: package
run: |
cd openwrt
make defconfig
make download -j8
find dl -size -1024c -exec ls -l {} \;
find dl -size -1024c -exec rm -f {} \;
- name: Compile the firmware
id: compile
run: |
cd openwrt
echo -e "$(($(nproc) + 1)) thread compile"
make -j$(($(nproc) + 1)) V=s || make -j1 || make -j1 V=s
echo "status=success" >> $GITHUB_OUTPUT
echo "COMPILE_DATE=$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV
- name: Check space usage
if: (!cancelled())
run: df -hT
- name: Organize compiled firmware
if: steps.compile.outputs.status == 'success' && !cancelled()
run: |
cp -rf openwrt/.config openwrt/bin/targets/x86/64/config
cd openwrt/bin/targets/x86/64
rm -rf *.buildinfo
rm -rf profiles.json
rm -rf sha256sums
rm -rf immortalwrt-x86-64-generic-kernel.bin
rm -rf immortalwrt-x86-64-generic.manifest
rm -rf immortalwrt-x86-64-generic-squashfs-rootfs.img.gz
mv immortalwrt-x86-64-generic-rootfs.tar.gz immortalwrt-${{ env.VERSION }}-x86-64-generic-rootfs-${{ env.COMPILE_DATE }}.tar.gz
mv immortalwrt-x86-64-generic-squashfs-combined-efi.img.gz immortalwrt-${{ env.VERSION }}-x86-64-generic-squashfs-combined-efi-${{ env.COMPILE_DATE }}.img.gz
- name: Upload firmware to release
if: steps.compile.outputs.status == 'success' && !cancelled()
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file_glob: true
file: openwrt/bin/targets/x86/64/*
asset_name: ${{ github.event.repository.name }}-${{ github.sha }}
tag: router-immortalwrt-${{ env.VERSION }}-x86_64-${{ env.COMPILE_DATE }}
body: |
### 主路由
- Default IP: 192.168.3.1
- Default username: root
- Default password: password
overwrite: true
- name: Delete workflow runs
uses: Mattraks/delete-workflow-runs@main
with:
retain_days: 0
keep_minimum_runs: 2
- name: Remove old releases
uses: dev-drprasad/delete-older-releases@master
with:
keep_latest: 4
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}