Add workflow file to trigger paths for self-testing #3
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: Build Content Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'data/**' | |
| - 'templates/**' | |
| - 'scripts/**' | |
| - '.github/workflows/build-content.yml' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'data/**' | |
| - 'templates/**' | |
| - 'scripts/**' | |
| - '.github/workflows/build-content.yml' | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| validate-and-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| cache-dependency-path: 'requirements-build.txt' | |
| - name: Install dependencies | |
| run: pip install -r requirements-build.txt | |
| - name: Validate data files | |
| working-directory: scripts | |
| run: python validate_data.py | |
| - name: Build HTML pages | |
| working-directory: scripts | |
| run: python build.py | |
| - name: Run tests | |
| run: python -m pytest tests/ -v | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| if [[ -n $(git status --porcelain *.html) ]]; then | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Commit and push changes | |
| if: github.event_name == 'push' && steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| git config user.name 'github-actions[bot]' | |
| git config user.email 'github-actions[bot]@users.noreply.github.com' | |
| git add publications.html people.html software.html | |
| git commit -m "Auto-build: Update content pages from spreadsheet data" | |
| git push |