diff --git a/.gitea/workflows/update-laws.yaml b/.gitea/workflows/update-laws.yaml index e93e35f1..ddbcb3e5 100644 --- a/.gitea/workflows/update-laws.yaml +++ b/.gitea/workflows/update-laws.yaml @@ -9,90 +9,62 @@ on: jobs: update: - runs-on: ubuntu-latest + runs-on: docker + container: + image: node:20-bookworm steps: - - name: Configure Git + - name: Install system dependencies run: | + apt-get update + apt-get install -y python3 python3-pip git 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 - git config --global http.lowSpeedLimit 0 - git config --global http.lowSpeedTime 0 - name: Checkout repository run: | - git clone --depth=1 https://git.coded.law/${{ github.repository }}.git . - git remote set-url origin https://git.coded.law/${{ github.repository }}.git + git clone --depth=1 https://lawgit-bot:${{ gitea.token }}@git.coded.law/${{ gitea.repository }}.git . git fetch --unshallow || true - - name: Set up Python + - name: Install Python dependencies run: | - python3 --version - # Create virtual environment - python3 -m venv venv - source venv/bin/activate - # Upgrade pip in venv - pip install --upgrade pip - # Make venv available for all steps - echo 'source venv/bin/activate' >> $GITHUB_ENV - - - name: Install dependencies - run: | - source venv/bin/activate - pip install --upgrade pip - pip install -r requirements.txt + pip install --break-system-packages -r requirements.txt - name: Run update script run: | - source venv/bin/activate - # Erstelle laws Verzeichnis falls es nicht existiert mkdir -p laws - python update_laws.py - continue-on-error: true # Weiterlaufen auch bei Fehlern + python3 update_laws.py + continue-on-error: true - name: Convert XML to Markdown - if: success() || failure() # Immer ausführen, auch wenn Update fehlschlug + if: always() run: | - source venv/bin/activate - # Erstelle laws Verzeichnis falls es nicht existiert mkdir -p laws - # Prüfe ob laws Verzeichnis existiert und nicht leer ist if [ -d "laws" ] && [ "$(ls -A laws 2>/dev/null)" ]; then - python xml_to_markdown.py --prod || echo "Konvertierung fehlgeschlagen oder keine Änderungen" + python3 xml_to_markdown.py --prod || echo "Konvertierung fehlgeschlagen oder keine Änderungen" else - echo "Info: laws Verzeichnis ist leer oder existiert nicht, überspringe Konvertierung" + echo "Info: laws Verzeichnis ist leer, überspringe Konvertierung" fi continue-on-error: true - - name: Check for changes - id: check_changes + - name: Commit and push changes run: | git add -A if git diff --staged --quiet; then - echo "changed=false" >> $GITHUB_OUTPUT echo "Keine Änderungen gefunden" else - echo "changed=true" >> $GITHUB_OUTPUT - echo "Änderungen gefunden" + 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: Commit and push changes - if: steps.check_changes.outputs.changed == 'true' - run: | - git commit -m "Update laws from RSS - $(date +'%Y-%m-%d %H:%M:%S UTC')" || exit 0 - # Push with timeout (10 minutes max) and progress output - timeout 600 git push --progress origin main 2>&1 || echo "Push fehlgeschlagen oder Timeout" - - name: Summary if: always() run: | echo "## Update-Zusammenfassung" echo "- Workflow ausgeführt: $(date)" - if [ "${{ steps.check_changes.outputs.changed }}" == "true" ]; then - echo "- OK: Änderungen wurden committed und auf main gepusht" - else - echo "- Info: Keine Änderungen gefunden" - fi - + echo "- Python: $(python3 --version)" + echo "- Git: $(git --version)"