Skip to content

Instantly share code, notes, and snippets.

@tumf
Created May 6, 2024 12:16
Show Gist options
  • Save tumf/3c831a40f0a5203cfc28d80b5dd6e9a6 to your computer and use it in GitHub Desktop.
Save tumf/3c831a40f0a5203cfc28d80b5dd6e9a6 to your computer and use it in GitHub Desktop.
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Python application
on:
push:
branches: [ "main" ]
paths:
- 'content/**/*.md'
env:
DIFY_DATASET_ID: ${{vars.DIFY_DATASET_ID}}
DIFY_API_KEY: ${{secrets.DIFY_API_KEY}}
permissions:
contents: read
jobs:
upload-knowledge:
runs-on: ubuntu-latest
outputs:
changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
any_changed: ${{ steps.changed-files.outputs.any_changed }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get changed files
uses: tj-actions/changed-files@v44.3.0
id: changed-files
with:
files: |
content/**/*.md
files_separator: "\n"
- name: Output changed files
run: echo ${{ steps.changed-files.outputs.all_changed_files }}
- name: Update RAG
run: |
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo "Processing updated file: $file"
if [[ $file == content/**/*.md ]]; then
python ./scripts/add_to_knowledge.py $file
fi
done
- name: Output deleted files
run: echo ${{ steps.changed-files.outputs.deleted_files }}
- name: Delete RAG
run: |
for file in ${{ steps.changed-files.outputs.deleted_files }}; do
echo "Processing deleted file: $file"
if [[ $file == content/**/*.md ]]; then
python ./scripts/delete_from_knowledge.py $file
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment