Main #363
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
| name: Main | |
| on: | |
| schedule: | |
| - cron: "10 22 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| update-rules: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # - name: Install Mihomo | |
| # env: | |
| # DEBIAN_FRONTEND: noninteractive | |
| # run: | | |
| # case "$(uname -m)" in | |
| # 'x86_64') ARCH='amd64' ;; | |
| # 'x86'|'i686'|'i386') ARCH='386' ;; | |
| # 'aarch64'|'arm64') ARCH='arm64' ;; | |
| # 'armv7l') ARCH='armv7' ;; | |
| # 'riscv64') ARCH='riscv64';; | |
| # 's390x') ARCH='s390x' ;; | |
| # *) ARCH='unknown';; | |
| # esac | |
| # echo "Detected architecture: $ARCH" | |
| # if [ "$ARCH" != 'unknown' ]; then | |
| # MIHOMO_VER=$(wget -qO- 'https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/version.txt') | |
| # MIHOMO_URL="https://github.com/MetaCubeX/mihomo/releases/download/Prerelease-Alpha/mihomo-linux-${ARCH}-${MIHOMO_VER}.deb" | |
| # wget -qO mihomo.deb "$MIHOMO_URL" | |
| # sudo apt-get install ./mihomo.deb | |
| # else | |
| # echo "Fail due to unsupported mihomo architecture" | |
| # exit 1 | |
| # fi | |
| - name: Download hosts file for StevenBlack | |
| run: curl -o StevenBlack.hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | |
| - name: Convert hosts to Mihomo rules yaml for StevenBlack | |
| run: python3 Source/Script/HostsToYAML.py StevenBlack.hosts StevenBlack.yaml | |
| # - name: Compile to Mihomo rules binary for StevenBlack | |
| # run: mihomo convert-ruleset domain yaml StevenBlack.yaml StevenBlack.mrs | |
| - name: Push to releases branch | |
| run: | | |
| current_date=$(date +'%Y-%m-%d') | |
| rm -rf .git/* | |
| git init | |
| git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
| git checkout -b release | |
| git config --global user.name 'GitHub Actions' | |
| git config --global user.email 'actions@github.com' | |
| git add *.yaml | |
| git commit -m "Update rules ($current_date)" | |
| git push origin release -f |