Update Search Database #396
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: Update Search Database | |
on: | |
schedule: | |
- cron: '0 4 * * *' # Run daily at 4:00 UTC | |
workflow_dispatch: # Allow manual trigger | |
push: | |
branches: [ main ] | |
paths: | |
- '**/*.md' | |
- '**/*.html' | |
- '.github/workflows/update-search.yml' | |
# Add permissions needed for the workflow | |
permissions: | |
contents: write # This allows the action to commit and push changes | |
jobs: | |
update-search: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for proper git operations | |
- name: Clone comphy-search repository | |
run: | | |
git clone https://github.com/comphy-lab/comphy-search.git | |
mkdir -p assets/js | |
- name: Copy search database | |
run: | | |
cp comphy-search/search_db.json assets/js/search_db.json | |
- name: Commit and push changes directly (bypassing branch protection) | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add assets/js/search_db.json | |
if git diff --staged --quiet; then | |
echo "No changes to commit" | |
else | |
git commit -m "Update search database from comphy-search repository" | |
# Use PAT to bypass branch protection | |
git push https://${{ secrets.BYPASS_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git HEAD:main | |
fi |