This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #================================================= | ||
| # Description: Build OpenWrt using GitHub Actions | ||
| # License: MIT | ||
| # Author: eSirPlayground | ||
| # Youtube Channel: https://goo.gl/fvkdwm | ||
| #================================================= | ||
| name: Build_Redmi_AX6000 | ||
| # Add a button to trigger the workflow | ||
| on: | ||
| schedule: | ||
| - cron: '0 4 * * *' | ||
| repository_dispatch: | ||
| workflow_dispatch: | ||
| inputs: | ||
| ssh: | ||
| description: 'SSH connection to Actions' | ||
| required: false | ||
| default: 'false' | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-22.04 | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@master | ||
| - name: Initialization environment | ||
| env: | ||
| DEBIAN_FRONTEND: noninteractive | ||
| run: | | ||
| docker rmi $(docker images -q) | ||
| sudo rm -rf /usr/share/dotnet /etc/apt/sources.list.d /usr/local/lib/android $AGENT_TOOLSDIRECTORY | ||
| sudo -E apt-get -y purge azure-cli ghc* zulu* llvm* firefox google* dotnet* powershell openjdk* mongodb* moby* || true | ||
| sudo -E apt-get -y update | ||
| sudo -E apt-get -y install $(curl -fsSL is.gd/depends_ubuntu_2204) | ||
| sudo -E systemctl daemon-reload | ||
| sudo -E apt-get -y autoremove --purge | ||
| sudo -E apt-get -y clean | ||
| sudo timedatectl set-timezone "Asia/Shanghai" | ||
| sudo mkdir -p /workdir | ||
| sudo chown $USER:$GROUPS /workdir | ||
| - name: 合并磁盘 Disks | ||
| uses: easimon/maximize-build-space@master | ||
| with: | ||
| swap-size-mb: 1024 | ||
| temp-reserve-mb: 100 | ||
| root-reserve-mb: 1024 | ||
| - name: 将github存储库签出到运行器 | ||
| uses: actions/checkout@v4 | ||
| - name: 设置immortalwrt源码地址,以及克隆 | ||
| env: | ||
| REPO_URL: https://github.com/immortalwrt/immortalwrt | ||
| REPO_BRANCH: v24.10.2 | ||
| UPLOAD_BIN_DIR: true | ||
| UPLOAD_FIRMWARE: true | ||
| run: | | ||
| git clone --depth 1 $REPO_URL -b $REPO_BRANCH openwrt | ||
| cd openwrt | ||
| #echo "src-git ssrp https://github.com/fw876/helloworld.git" >> ./feeds.conf.default | ||
| - name: Update & Install feeds | ||
| working-directory: ./openwrt | ||
| run: | | ||
| ./scripts/feeds update -a | ||
| ./scripts/feeds install -a | ||
| - name: Configuration Customization - Build_Redmi_AC2100 | ||
| env: | ||
| CONFIG_FILE: 'redmi_ac2100.config' | ||
| run: | | ||
| [ -e $CONFIG_FILE ] && mv -f $CONFIG_FILE openwrt/.config | ||
| cd openwrt && make defconfig | ||
| ls | ||
| - name: SSH connection to Actions | ||
| uses: eyu-dev/debugger-action@master | ||
| # uses: danshui-git/debugger-action@main | ||
| 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: 自定义设置类 | ||
| run: | | ||
| #删除旧版openclash | ||
| ls | ||
| rm -rf openwrt/package/feeds/luci/luci-app-openclash | ||
| ls | ||
| chmod +x ./customize.sh && ./customize.sh | ||
| chmod +x $GITHUB_WORKSPACE/patches/*.sh | ||
| cd openwrt/package/feeds/luci | ||
| #执行自定义插件 | ||
| $GITHUB_WORKSPACE/patches/Plugins.sh | ||
| - name: Download package | ||
| working-directory: ./openwrt | ||
| run: | | ||
| make download -j$(nproc) | ||
| find dl -size -1024c -exec ls -l {} \; | ||
| find dl -size -1024c -exec rm -f {} \; | ||
| - name: Build firmware | ||
| working-directory: ./openwrt | ||
| run: | | ||
| echo -e "$(nproc) thread build." | ||
| make -j $(($(nproc)+1)) || make -j$(nproc) V=s || make -j1 V=s | ||
| echo "status=success" >> $GITHUB_OUTPUT | ||
| grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/' > DEVICE_NAME | ||
| [ -s DEVICE_NAME ] && echo "DEVICE_NAME=_$(cat DEVICE_NAME)" >> $GITHUB_ENV | ||
| echo "FILE_DATE=_$(date +"%Y%m%d%H%M")" >> $GITHUB_ENV | ||
| # 获取固件架构 | ||
| DEVICE_TARGET=$(cat .config | grep CONFIG_TARGET_BOARD | awk -F '"' '{print $2}') | ||
| echo "DEVICE_TARGET=$DEVICE_TARGET" >> $GITHUB_ENV | ||
| DEVICE_SUBTARGET=$(cat .config | grep CONFIG_TARGET_SUBTARGET | awk -F '"' '{print $2}') | ||
| echo "DEVICE_SUBTARGET=$DEVICE_SUBTARGET" >> $GITHUB_ENV | ||
| - name: 固件上传 artifact | ||
| uses: actions/upload-artifact@master | ||
| with: | ||
| name: OpenWrt | ||
| path: openwrt/bin/targets | ||
| #软件包分类 | ||
| - name: Package Firmware | ||
| run: | | ||
| #在openwrt目录下创建目录为upload目录名 | ||
| cd ./openwrt && mkdir ./upload | ||
| rm -rf $(find ./bin/targets/ -iregex ".*\(json\|buildinfo\|sha256sums\|packages\)$") | ||
| cp -rf $(find ./bin/targets/ -type f -iname "*.*") ./upload/ | ||
| cp -rf ./.config ./upload/Config_"Redmi-ax6000"_"imm源码"_"$FILE_DATE".txt | ||
| cd /bin/targets/*/* | ||
| echo "KERNEL=$(cat *.manifest | grep ^kernel | cut -d- -f2 | tr -d ' ')" >> $GITHUB_ENV | ||
| cd ./upload | ||
| echo "KERNEL=$(cat *.manifest | grep ^kernel | cut -d- -f2 | tr -d ' ')" >> $GITHUB_ENV | ||
| - name: Organize files | ||
| id: organize | ||
| if: env.UPLOAD_FIRMWARE == 'true' && !cancelled() | ||
| run: | | ||
| cd | ||
| cd openwrt/bin/targets/*/* | ||
| rm -rf packages | ||
| rm -rf *.buildinfo | ||
| rm -rf sha256sums | ||
| # rm -rf *.manifest | ||
| rm -rf *rootfs.img.gz | ||
| rm -rf *.json | ||
| rm -rf *.qcow2 | ||
| echo "FIRMWARE=$PWD" >> $GITHUB_ENV | ||
| echo "status=success" >> $GITHUB_OUTPUT | ||
| - name: Upload firmware directory | ||
| uses: actions/upload-artifact@master | ||
| if: ${{ steps.organize.outputs.status == 'success' && !cancelled() }} | ||
| with: | ||
| name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }} | ||
| path: ${{ env.FIRMWARE }} | ||
| - name: Generate release tag | ||
| id: tag | ||
| run: | | ||
| echo "release_tag=$(date +"%Y.%m.%d_%H.%M.%S-redmiax6000")" >> $GITHUB_OUTPUT | ||
| touch release.txt | ||
| echo "### 📒 固件信息" >> release.txt | ||
| echo "Redmi-ax6000 自用精简" >> release.txt | ||
| echo "- 💻 平台架构: ${{ env.DEVICE_TARGET }}-${{ env.DEVICE_SUBTARGET }}" >> release.txt | ||
| echo "- 🚀 内核版本: ${{ env.KERNEL }}" >> release.txt | ||
| echo "- 🌐 默认地址: 192.168.31.1" >> release.txt | ||
| echo "账号:root" >> release.txt | ||
| echo "- 🔑 默认密码: 空 或者 password" >> release.txt | ||
| echo "编译的源码取自:https://github.com/immortalwrt/immortalwrt" >> release.txt | ||
| echo "集成插件:1、openclash[集成Meta内核] 2、TTYD 终端 3、网络唤醒 4、frp客户端 5、frp服务端 | ||
| 6、alist 7、UPNP" >> release.txt | ||
| echo "默认主题:Argon" >> release.txt | ||
| echo "status=success" >> $GITHUB_OUTPUT | ||
| #上传固件以发布 | ||
| - name: Upload firmware to release | ||
| uses: softprops/action-gh-release@master | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| with: | ||
| tag_name: ${{ steps.tag.outputs.release_tag }} | ||
| body_path: release.txt | ||
| files: ./openwrt/upload/*.* | ||
| - name: 上传日志 | ||
| if: success() || failure() | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: openwrt-build-logs | ||
| path: | | ||
| openwrt/build_dir/**/*.log | ||
| openwrt/logs/* | ||
| openwrt/tmp/*.log | ||
| # retention-days: 3 # 可选,设置日志保留天数 | ||
| - name: Delete workflow runs | ||
| uses: GitRML/delete-workflow-runs@main | ||
| with: | ||
| retain_days: 1 | ||
| keep_minimum_runs: 3 | ||
| - name: Remove old Releases | ||
| uses: dev-drprasad/[email protected] | ||
| with: | ||
| keep_latest: 3 | ||
| delete_tags: true | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||