Files
lawgit/.gitea/workflows/update-laws.yaml

84 lines
2.7 KiB
YAML

name: Update Laws from RSS
on:
schedule:
# Täglich um 02:00 UTC (03:00 MEZ / 04:00 MESZ)
- cron: '0 2 * * *'
# Manueller Trigger für Tests
workflow_dispatch:
jobs:
update:
runs-on: ubuntu-latest
steps:
- name: Check environment
run: |
echo "=== System Info ==="
uname -a
echo "=== Python ==="
python3 --version
echo "=== Pip ==="
pip3 --version || pip --version || echo "pip nicht gefunden"
echo "=== Git ==="
git --version
echo "=== Welche Shell ==="
echo $SHELL
which python3 pip3 git
- name: Configure Git
run: |
git config --global user.name 'LawGit Bot'
git config --global user.email 'bot@git.coded.law'
git config --global init.defaultBranch main
git config --global http.postBuffer 524288000
- name: Checkout repository
run: |
git clone --depth=1 https://lawgit-bot:${{ gitea.token }}@git.coded.law/${{ gitea.repository }}.git .
git fetch --unshallow || true
- name: Install Python dependencies
run: |
pip3 install --break-system-packages -r requirements.txt || \
pip install --break-system-packages -r requirements.txt || \
pip3 install -r requirements.txt || \
pip install -r requirements.txt
- name: Run update script
run: |
mkdir -p laws
python3 update_laws.py
continue-on-error: true
- name: Convert XML to Markdown
if: always()
run: |
mkdir -p laws
if [ -d "laws" ] && [ "$(ls -A laws 2>/dev/null)" ]; then
python3 xml_to_markdown.py --prod || echo "Konvertierung fehlgeschlagen oder keine Änderungen"
else
echo "Info: laws Verzeichnis ist leer, überspringe Konvertierung"
fi
continue-on-error: true
- name: Commit and push changes
run: |
git add -A
if git diff --staged --quiet; then
echo "Keine Änderungen gefunden"
else
echo "Änderungen gefunden:"
git status
git commit -m "Update laws from RSS - $(date +'%Y-%m-%d %H:%M:%S UTC')"
git remote set-url origin https://lawgit-bot:${{ gitea.token }}@git.coded.law/${{ gitea.repository }}.git
timeout 600 git push --progress origin main 2>&1 || echo "Push fehlgeschlagen oder Timeout"
fi
- name: Summary
if: always()
run: |
echo "## Update-Zusammenfassung"
echo "- Workflow ausgeführt: $(date)"
echo "- Python: $(python3 --version 2>&1)"
echo "- Git: $(git --version 2>&1)"