Data Sync #218
This file contains hidden or 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: Data Sync | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' # Daily at 6:00 UTC | |
| workflow_dispatch: | |
| inputs: | |
| force: | |
| description: 'Force reprocess all documents (ignore .completed)' | |
| type: boolean | |
| default: false | |
| limit: | |
| description: 'Max documents to process (0 = all)' | |
| type: string | |
| default: '0' | |
| concurrency: | |
| group: data-sync | |
| cancel-in-progress: false | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 300 | |
| permissions: | |
| contents: write | |
| env: | |
| GIT_LFS_SKIP_SMUDGE: 1 | |
| steps: | |
| - name: Checkout (LFS pointers only) | |
| uses: actions/checkout@v4 | |
| with: | |
| lfs: false | |
| fetch-depth: 1 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Configure Git LFS credentials | |
| env: | |
| LFS_USERNAME: ${{ vars.GIT_LFS_USERNAME }} | |
| LFS_PASSWORD: ${{ secrets.GIT_LFS_PASSWORD }} | |
| run: | | |
| git lfs install | |
| git config lfs.url "https://${LFS_USERNAME}:${LFS_PASSWORD}@git-lfs.nordstemmen-ai.levinkeller.de" | |
| git config lfs.https://git-lfs.nordstemmen-ai.levinkeller.de.locksverify false | |
| - name: Run scraper | |
| env: | |
| OPARL_PROXY_URL: https://nordstemmen.ratsinfomanagement.levinkeller.de | |
| OPARL_PROXY_SECRET: nordstemmen-oparl-2026 | |
| run: npm run scrape | |
| working-directory: scraper | |
| - name: Check for new documents | |
| id: check | |
| run: | | |
| NEW_FILES=$(git status documents/ --porcelain | wc -l) | |
| echo "new_files=$NEW_FILES" >> "$GITHUB_OUTPUT" | |
| FORCE="${{ inputs.force || 'false' }}" | |
| echo "force=$FORCE" >> "$GITHUB_OUTPUT" | |
| if [ "$NEW_FILES" -eq 0 ] && [ "$FORCE" != "true" ]; then | |
| echo "No new documents found. Nothing to do." | |
| else | |
| echo "Found $NEW_FILES new/changed files in documents/" | |
| fi | |
| - name: Run pipeline | |
| if: steps.check.outputs.new_files != '0' || steps.check.outputs.force == 'true' | |
| env: | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| JINA_API_KEY: ${{ secrets.JINA_API_KEY }} | |
| QDRANT_URL: ${{ vars.QDRANT_URL }} | |
| QDRANT_API_KEY: ${{ secrets.QDRANT_API_KEY }} | |
| QDRANT_PORT: '443' | |
| run: | | |
| ARGS="" | |
| if [ "${{ inputs.force || 'false' }}" = "true" ]; then | |
| ARGS="$ARGS --force" | |
| fi | |
| LIMIT="${{ inputs.limit || '0' }}" | |
| if [ "$LIMIT" != "0" ]; then | |
| ARGS="$ARGS --limit $LIMIT" | |
| fi | |
| npm run pipeline -- $ARGS | |
| - name: Commit and push new data | |
| if: steps.check.outputs.new_files != '0' || steps.check.outputs.force == 'true' | |
| run: | | |
| git add documents/ | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git commit -m "data: sync new documents from OParl API" || echo "Nothing to commit" | |
| git pull --rebase origin main | |
| git push |