Update Catalog Data #114
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 Catalog Data | |
| on: | |
| schedule: | |
| - cron: "0 6 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| update-data: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 60 | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: "pip" | |
| cache-dependency-path: requirements.txt | |
| - name: Install dependencies | |
| run: python -m pip install --upgrade pip && pip install -r requirements.txt | |
| - name: Refresh catalog data from Wikidata | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: python scripts/fetch_data.py | |
| - name: Generate detail pages | |
| run: python scripts/generate_pages.py | |
| - name: Detect data changes | |
| id: changes | |
| run: | | |
| git add data/ontologies.ttl data/software.ttl data/ontologies.json data/software.json data/categories.json data/page_qids.json site/resource site/software site/sitemap.xml | |
| if git diff --cached --quiet; then | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Commit updated data | |
| if: steps.changes.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git commit -m "chore(data): refresh catalog from Wikidata" | |
| - name: Push updated data | |
| if: steps.changes.outputs.changed == 'true' | |
| run: git push origin "HEAD:${GITHUB_REF_NAME}" | |
| - name: Trigger deploy | |
| if: steps.changes.outputs.changed == 'true' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'deploy.yml', | |
| ref: 'main', | |
| }); | |
| - name: No changes detected | |
| if: steps.changes.outputs.changed != 'true' | |
| run: echo "No data changes to commit." |