Generate routing rules for Shadowrocket #486
This file contains 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: Generate routing rules for Shadowrocket | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "30 23 * * *" | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- "**/README.md" | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set variables | |
run: echo "RELEASE_NAME=Released on $(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
shell: bash | |
- name: Make directory | |
run: mkdir publish | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
cache: 'pip' | |
- name: Install dependencies | |
run: pip install -r requirements.txt | |
- name: Generate rule.conf file | |
run: | | |
python3 build.py | |
- name: Move files to publish directory | |
run: mv rule.conf publish | |
- name: Git push assets to "release" branch | |
run: | | |
cd publish || exit 1 | |
git init | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git checkout -b release | |
git add . | |
git commit -m "${{ env.RELEASE_NAME }}" | |
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" | |
git push -f -u origin release | |
- name: Purge jsdelivr CDN | |
run: | | |
cd publish || exit 1 | |
curl -i "https://purge.jsdelivr.net/gh/${{ github.repository }}@release/rule.conf" |