Skip to content

Build

Build #1003

Workflow file for this run

name: Build
on:
push:
branches:
- master
schedule:
- cron: "0 0,6,12,18 * * *"
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install sing-box
run: |
set -e -o pipefail
bash <(curl -fsSL https://sing-box.app/install.sh)
- name: Install mihomo
run: |
set -e -o pipefail
sudo apt-get update && sudo apt-get install -y jq
DOWNLOAD_URL=$(curl -s https://api.github.com/repos/MetaCubeX/mihomo/releases/latest | jq -r '.assets[] | select(.name | contains("linux-amd64-v3") and endswith(".gz") and contains("go") == false) | .browser_download_url' | head -n1)
if [ -z "$DOWNLOAD_URL" ] || [ "$DOWNLOAD_URL" = "null" ]; then
echo "Error: Could not find linux-amd64-v3.gz asset"
exit 1
fi
echo "Downloading from: $DOWNLOAD_URL"
curl -L -o mihomo.gz "$DOWNLOAD_URL"
gunzip mihomo.gz
chmod +x mihomo
sudo mv mihomo /usr/local/bin/
# Verify installation
mihomo -v
- name: Install uv
uses: astral-sh/setup-uv@v6
- run: |
set -e -o pipefail
uv sync
uv run rule-set
- name: Pre-deploy check
run: |
if [ -f .failure ]; then
echo "rule-set generation failed"
exit 1
fi
- run: |
set -e -o pipefail
mkdir deploy_temp
cd deploy_temp
git init
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git remote add origin https://github-action:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
git fetch origin
if git rev-parse --verify origin/release >/dev/null 2>&1; then
git checkout release
else
git checkout --orphan release
fi
cd ..
- name: restore timestamps
uses: chetan/git-restore-mtime-action@v2
with:
working-directory: "deploy_temp"
- name: Deploy to release branch
run: |
set -e -o pipefail
cd deploy_temp
rsync -rvc --delete --exclude='.git' ../rule-set/ .
# Generate GitHub Pages navigation
echo "Generating pages in deploy_temp directory..."
uv run gen-pages --target-path .
if [[ -z $(git status --porcelain) ]]; then
echo "No changes to commit."
else
git add .
git commit -m "Update release"
git push origin release
fi