make rule cache #36
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: 'make rule cache' | |
on: | |
# Allows you to run this workflow manually from the Actions tab or through HTTP API | |
workflow_dispatch: | |
schedule: | |
- cron: "0 16 1/7 * *" | |
push: | |
branches: | |
- custom-rules | |
- main | |
paths: | |
- '*.list' | |
- '.github/workflows/update-rules.yml' | |
- 'mkcache.py' | |
- 'modules/rule.py' | |
- 'config.py' | |
permissions: | |
contents: write | |
jobs: | |
sync: | |
name: 'make rule cache' | |
runs-on: ubuntu-latest | |
if: github.repository != 'SubConv/SubConv-4-ZJU' | |
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
# Checkout the repository to the GitHub Actions runner | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
submodules: true | |
- name: Setup Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Setup Python dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Make Rule Cache | |
run: | | |
git pull | |
git checkout main | |
python mkcache.py | |
- name: Commit update | |
run: | | |
git config --global user.name 'Git bot' | |
git config --global user.email '[email protected]' | |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} | |
git add -A | |
git commit -am "Auto updated rules" && git push || echo "No changes to commit" |