Sync RAGFlow #6
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: Sync RAGFlow | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| batch_size: | |
| description: 'Number of docs to sync (0 = all)' | |
| required: false | |
| default: '5' | |
| dry_run: | |
| description: 'Dry run (no uploads)' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| force: | |
| description: 'Force re-sync all docs (clears ragflow_source_hash)' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| verify: | |
| description: 'Verify synced docs exist in RAGFlow before syncing' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| permissions: | |
| contents: write | |
| env: | |
| PYTHONUNBUFFERED: "1" | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Set up venv and install dependencies | |
| run: | | |
| python -m venv venv | |
| source venv/bin/activate | |
| pip install -r requirements.txt | |
| - name: Sync to RAGFlow | |
| env: | |
| RAGFLOW_API_KEY: ${{ secrets.RAGFLOW_API_KEY }} | |
| RAGFLOW_BASE_URL: ${{ secrets.RAGFLOW_BASE_URL }} | |
| BATCH_SIZE: ${{ github.event.inputs.batch_size || '5' }} | |
| DRY_RUN: ${{ github.event.inputs.dry_run || 'false' }} | |
| run: | | |
| source venv/bin/activate | |
| ARGS="" | |
| if [ "${{ github.event.inputs.force }}" = "true" ]; then ARGS="$ARGS --force"; fi | |
| if [ "${{ github.event.inputs.verify }}" = "true" ]; then ARGS="$ARGS --verify"; fi | |
| python scripts/sync-ragflow.py $ARGS | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit changes (if any) | |
| run: | | |
| git add config/processing-state.json | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit." | |
| exit 0 | |
| fi | |
| ts="$(date -u +"%Y-%m-%d %H:%M:%S UTC")" | |
| git commit -m "Sync RAGFlow keywords ($ts)" | |
| git push origin HEAD:${{ github.ref_name }} |