[
  {
    "path": ".config",
    "content": "# This is an empty file, please overwrite it after generating the .config file with the source code"
  },
  {
    "path": ".github/workflows/openwrt-builder.yml",
    "content": "#\n# https://github.com/P3TERX/Actions-OpenWrt\n#\n# File: .github/workflows/openwrt-bulder.yml\n# Description: Build OpenWrt using GitHub Actions\n#\n# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>\n#\n# This is free software, licensed under the MIT License.\n# See /LICENSE for more information.\n#\n\nname: OpenWrt Builder\n\non:\n  repository_dispatch:\n  workflow_dispatch:\n\nenv:\n  REPO_URL: https://github.com/coolsnowwolf/lede\n  REPO_BRANCH: master\n  FEEDS_CONF: feeds.conf.default\n  CONFIG_FILE: .config\n  DIY_P1_SH: diy-part1.sh\n  DIY_P2_SH: diy-part2.sh\n  UPLOAD_BIN_DIR: false\n  UPLOAD_FIRMWARE: true\n  UPLOAD_RELEASE: true\n  TZ: Asia/Shanghai\n\njobs:\n  build:\n    runs-on: ubuntu-22.04\n\n    steps:\n    - name: Checkout\n      uses: actions/checkout@main\n\n    - name: Initialization environment\n      env:\n        DEBIAN_FRONTEND: noninteractive\n      run: |\n        sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL\n        sudo docker image prune --all --force\n        sudo -E apt-get -qq update\n        sudo -E apt-get -qq install ack antlr3 asciidoc autoconf automake autopoint binutils bison build-essential bzip2 ccache cmake cpio curl device-tree-compiler fastjar flex gawk gettext gcc-multilib g++-multilib git gperf haveged help2man intltool libc6-dev-i386 libelf-dev libfuse-dev libglib2.0-dev libgmp3-dev libltdl-dev libmpc-dev libmpfr-dev libncurses5-dev libncursesw5-dev libpython3-dev libreadline-dev libssl-dev libtool lrzsz mkisofs msmtp ninja-build p7zip p7zip-full patch pkgconf python2.7 python3 python3-pyelftools python3-setuptools qemu-utils rsync scons squashfs-tools subversion swig texinfo uglifyjs upx-ucl unzip vim wget xmlto xxd zlib1g-dev\n        sudo -E apt-get -qq autoremove --purge\n        sudo -E apt-get -qq clean\n        sudo timedatectl set-timezone \"$TZ\"\n        sudo mkdir -p /workdir\n        sudo chown $USER:$GROUPS /workdir\n\n    - name: Clone source code\n      working-directory: /workdir\n      run: |\n        df -hT $PWD\n        git clone $REPO_URL -b $REPO_BRANCH openwrt\n        ln -sf /workdir/openwrt $GITHUB_WORKSPACE/openwrt\n\n    - name: Load custom feeds\n      run: |\n        [ -e $FEEDS_CONF ] && mv $FEEDS_CONF openwrt/feeds.conf.default\n        chmod +x $DIY_P1_SH\n        cd openwrt\n        $GITHUB_WORKSPACE/$DIY_P1_SH\n\n    - name: Update feeds\n      run: cd openwrt && ./scripts/feeds update -a\n\n    - name: Install feeds\n      run: cd openwrt && ./scripts/feeds install -a\n\n    - name: Load custom configuration\n      run: |\n        [ -e files ] && mv files openwrt/files\n        [ -e $CONFIG_FILE ] && mv $CONFIG_FILE openwrt/.config\n        chmod +x $DIY_P2_SH\n        cd openwrt\n        $GITHUB_WORKSPACE/$DIY_P2_SH\n\n    - name: Download package\n      id: package\n      run: |\n        cd openwrt\n        make defconfig\n        make download -j8\n        find dl -size -1024c -exec ls -l {} \\;\n        find dl -size -1024c -exec rm -f {} \\;\n\n    - name: Compile the firmware\n      id: compile\n      run: |\n        cd openwrt\n        echo -e \"$(nproc) thread compile\"\n        make -j$(nproc) || make -j1 || make -j1 V=s\n        echo \"status=success\" >> $GITHUB_OUTPUT\n        grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\\1/' > DEVICE_NAME\n        [ -s DEVICE_NAME ] && echo \"DEVICE_NAME=_$(cat DEVICE_NAME)\" >> $GITHUB_ENV\n        echo \"FILE_DATE=_$(date +\"%Y%m%d%H%M\")\" >> $GITHUB_ENV\n\n    - name: Check space usage\n      if: (!cancelled())\n      run: df -hT\n\n    - name: Upload bin directory\n      uses: actions/upload-artifact@main\n      if: steps.compile.outputs.status == 'success' && env.UPLOAD_BIN_DIR == 'true'\n      with:\n        name: OpenWrt_bin${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}\n        path: openwrt/bin\n\n    - name: Organize files\n      id: organize\n      if: env.UPLOAD_FIRMWARE == 'true' && !cancelled()\n      run: |\n        cd openwrt/bin/targets/*/*\n        rm -rf packages\n        echo \"FIRMWARE=$PWD\" >> $GITHUB_ENV\n        echo \"status=success\" >> $GITHUB_OUTPUT\n\n    - name: Upload firmware directory\n      uses: actions/upload-artifact@main\n      if: steps.organize.outputs.status == 'success' && !cancelled()\n      with:\n        name: OpenWrt_firmware${{ env.DEVICE_NAME }}${{ env.FILE_DATE }}\n        path: ${{ env.FIRMWARE }}\n\n    - name: Generate release tag\n      id: tag\n      if: env.UPLOAD_RELEASE == 'true' && !cancelled()\n      run: |\n        echo \"release_tag=$(date +\"%Y.%m.%d-%H%M\")\" >> $GITHUB_OUTPUT\n        touch release.txt\n        [ ${UPLOAD_GOFILE} = true && ${{ steps.gofile.outputs.url }} ] && echo \"🔗 [GoFile](${{ steps.gofile.outputs.url }})\" >> release.txt\n        echo \"status=success\" >> $GITHUB_OUTPUT\n\n    - name: Upload firmware to release\n      uses: softprops/action-gh-release@master\n      if: steps.tag.outputs.status == 'success' && !cancelled()\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n      with:\n        tag_name: ${{ steps.tag.outputs.release_tag }}\n        body_path: release.txt\n        files: ${{ env.FIRMWARE }}/*\n\n    - name: Delete workflow runs\n      uses: Mattraks/delete-workflow-runs@main\n      with:\n        retain_days: 0\n        keep_minimum_runs: 2\n\n    - name: Remove old Releases\n      uses: dev-drprasad/delete-older-releases@master\n      if: env.UPLOAD_RELEASE == 'true' && !cancelled()\n      with:\n        keep_latest: 3\n        delete_tags: true\n      env:\n        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}\n"
  },
  {
    "path": ".github/workflows/update-checker.yml",
    "content": "#\n# https://github.com/P3TERX/Actions-OpenWrt\n#\n# File: .github/workflows/update-checker.yml\n# Description: Source code update checker\n#\n# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>\n#\n# This is free software, licensed under the MIT License.\n# See /LICENSE for more information.\n#\n\nname: Update Checker\n\nenv:\n  REPO_URL: https://github.com/coolsnowwolf/lede\n  REPO_BRANCH: master\n\non:\n  workflow_dispatch:\n#  schedule:\n#    - cron: 0 */18 * * *\n\njobs:\n  check:\n    runs-on: ubuntu-latest\n\n    steps:\n\n    - name: Get Commit Hash\n      id: getHash\n      run: |\n        git clone --depth 1 $REPO_URL -b $REPO_BRANCH .\n        echo \"commitHash=$(git rev-parse HEAD)\" >> $GITHUB_OUTPUT\n\n    - name: Compare Commit Hash\n      id: cacheHash\n      uses: actions/cache@v3\n      with:\n        path: .commitHash\n        key: commitHash_${{ steps.getHash.outputs.commitHash }}\n\n    - name: Save New Commit Hash\n      if: steps.cacheHash.outputs.cache-hit != 'true'\n      run: |\n        echo ${{ steps.getHash.outputs.commitHash }} | tee .commitHash\n\n    - name: Trigger build\n      if: steps.cacheHash.outputs.cache-hit != 'true'\n      uses: peter-evans/repository-dispatch@v2\n      with:\n        token: ${{ github.token }}\n        event-type: Source Code Update\n\n    - name: Delete workflow runs\n      uses: Mattraks/delete-workflow-runs@v2\n      with:\n        retain_days: 0\n        keep_minimum_runs: 2\n"
  },
  {
    "path": "LICENSE",
    "content": "MIT License\n\nCopyright (c) 2019-2024 P3TERX <https://p3terx.com>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "**English** | [中文](https://p3terx.com/archives/build-openwrt-with-github-actions.html)\n\n# Actions-OpenWrt\n\n[![LICENSE](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square&label=LICENSE)](https://github.com/P3TERX/Actions-OpenWrt/blob/master/LICENSE)\n![GitHub Stars](https://img.shields.io/github/stars/P3TERX/Actions-OpenWrt.svg?style=flat-square&label=Stars&logo=github)\n![GitHub Forks](https://img.shields.io/github/forks/P3TERX/Actions-OpenWrt.svg?style=flat-square&label=Forks&logo=github)\n\nA template for building OpenWrt with GitHub Actions\n\n## Usage\n\n- Click the [Use this template](https://github.com/P3TERX/Actions-OpenWrt/generate) button to create a new repository.\n- Generate `.config` files using [Lean's OpenWrt](https://github.com/coolsnowwolf/lede) source code. ( You can change it through environment variables in the workflow file. )\n- Push `.config` file to the GitHub repository.\n- Select `Build OpenWrt` on the Actions page.\n- Click the `Run workflow` button.\n- When the build is complete, click the `Artifacts` button in the upper right corner of the Actions page to download the binaries.\n\n## Tips\n\n- It may take a long time to create a `.config` file and build the OpenWrt firmware. Thus, before create repository to build your own firmware, you may check out if others have already built it which meet your needs by simply [search `Actions-Openwrt` in GitHub](https://github.com/search?q=Actions-openwrt).\n- Add some meta info of your built firmware (such as firmware architecture and installed packages) to your repository introduction, this will save others' time.\n\n## Credits\n\n- [Microsoft Azure](https://azure.microsoft.com)\n- [GitHub Actions](https://github.com/features/actions)\n- [OpenWrt](https://github.com/openwrt/openwrt)\n- [coolsnowwolf/lede](https://github.com/coolsnowwolf/lede)\n- [Mikubill/transfer](https://github.com/Mikubill/transfer)\n- [softprops/action-gh-release](https://github.com/softprops/action-gh-release)\n- [Mattraks/delete-workflow-runs](https://github.com/Mattraks/delete-workflow-runs)\n- [dev-drprasad/delete-older-releases](https://github.com/dev-drprasad/delete-older-releases)\n- [peter-evans/repository-dispatch](https://github.com/peter-evans/repository-dispatch)\n\n## License\n\n[MIT](https://github.com/P3TERX/Actions-OpenWrt/blob/main/LICENSE) © [**P3TERX**](https://p3terx.com)\n"
  },
  {
    "path": "diy-part1.sh",
    "content": "#!/bin/bash\n#\n# https://github.com/P3TERX/Actions-OpenWrt\n# File name: diy-part1.sh\n# Description: OpenWrt DIY script part 1 (Before Update feeds)\n#\n# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>\n#\n# This is free software, licensed under the MIT License.\n# See /LICENSE for more information.\n#\n\n# Uncomment a feed source\n#sed -i 's/^#\\(.*helloworld\\)/\\1/' feeds.conf.default\n\n# Add a feed source\necho 'src-git helloworld https://github.com/fw876/helloworld' >>feeds.conf.default\n#echo 'src-git passwall https://github.com/xiaorouji/openwrt-passwall' >>feeds.conf.default\n"
  },
  {
    "path": "diy-part2.sh",
    "content": "#!/bin/bash\n#\n# https://github.com/P3TERX/Actions-OpenWrt\n# File name: diy-part2.sh\n# Description: OpenWrt DIY script part 2 (After Update feeds)\n#\n# Copyright (c) 2019-2024 P3TERX <https://p3terx.com>\n#\n# This is free software, licensed under the MIT License.\n# See /LICENSE for more information.\n#\n\n# Modify default IP\n#sed -i 's/192.168.1.1/192.168.50.5/g' package/base-files/files/bin/config_generate\n\n# Modify default theme\n#sed -i 's/luci-theme-bootstrap/luci-theme-argon/g' feeds/luci/collections/luci/Makefile\n\n# Modify hostname\n#sed -i 's/OpenWrt/P3TERX-Router/g' package/base-files/files/bin/config_generate\n"
  }
]