name: build sha on: push: branches: - 'master' paths: - '.github/workflows/**' schedule: - cron: '20 16 * * *' jobs: build-sha: runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v3 with: python-version: '3.10' - name: Install dependencies run: | python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Check out ip-lists branch of gaoyifan/china-operator-ip uses: actions/checkout@v3 with: repository: gaoyifan/china-operator-ip ref: ip-lists path: ip-lists - name: Checkout sha branch uses: actions/checkout@v3 with: ref: sha path: sha - name: Clean sha branch continue-on-error: true run: rm sha/* - name: Rebuild sha branch run: | ./netgen.py ip-lists/china.txt -o sha/china.txt -p 'ip route add ' -s $' dev eth0 via 10.11.0.1\n' ./netgen.py ip-lists/china6.txt -o sha/china6.txt -p 'ip route add ' -s $' dev eth0 via fe80::6a77:24ff:fed6:809d\n' - name: Push to sha branch continue-on-error: true run: | cd sha tar -cf sha.tar *.txt rm *.txt git config --global user.name "${GITHUB_ACTOR}" git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" git add . git commit -m "update $(date +%Y-%m-%d)" git push -q