Files
shunt-rules/.gitea/workflows/generate-rules.yml
T

72 lines
1.7 KiB
YAML

name: Generate Rules
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * *"
push:
branches:
- main
paths:
- main.py
- config.toml
- config.json
- .gitea/workflows/generate-rules.yml
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
github-server-url: https://git.halonice.com
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Prepare config
shell: bash
run: |
if [ -f config.toml ]; then
echo "Use existing config.toml"
elif [ -f config.json ]; then
echo "Use existing config.json"
elif [ -f config.example.toml ]; then
cp config.example.toml config.toml
echo "Generated config.toml from example"
else
echo "No config file found" >&2
exit 1
fi
- name: Generate rules
env:
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
run: |
if [ -f config.toml ]; then
python3 main.py --config config.toml
else
python3 main.py --config config.json
fi
- name: Commit and push dist changes
shell: bash
run: |
if [ -n "$(git status --porcelain dist)" ]; then
git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions@localhost"
git add dist
git commit -m "chore: update generated rules"
git push
else
echo "No changes in dist/"
fi