update citations #4
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-citations | |
| run-name: update citations | |
| on: | |
| # run when called from another workflow | |
| workflow_call: | |
| inputs: | |
| open-pr: | |
| type: boolean | |
| outputs: | |
| changed: | |
| value: ${{ jobs.update-citations.outputs.changed }} | |
| # run if user manually requests it | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| env: | |
| FORCE_COLOR: true | |
| GOOGLE_SCHOLAR_API_KEY: ${{ secrets.GOOGLE_SCHOLAR_API_KEY }} | |
| jobs: | |
| update-citations: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - name: Debug dump | |
| uses: crazy-max/ghaction-dump-context@v2 | |
| - name: Checkout branch contents | |
| if: github.event.action != 'closed' | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.head_ref }} | |
| - name: Setup Python | |
| if: github.event.action != 'closed' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| cache: "pip" | |
| cache-dependency-path: "**/requirements.txt" | |
| - name: Install Python packages | |
| if: github.event.action != 'closed' | |
| run: | | |
| python -m pip install --upgrade --requirement ./_cite/requirements.txt | |
| - name: SSH debug | |
| if: runner.debug == '1' | |
| uses: mxschmitt/action-tmate@v3 | |
| - name: Build updated citations | |
| if: github.event.action != 'closed' | |
| run: python _cite/cite.py | |
| timeout-minutes: 15 | |
| - name: Commit cache | |
| if: failure() | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| file_pattern: "**/.cache/**" | |
| commit_message: "Commit cache" | |
| - name: Check if citations changed | |
| if: github.event.action != 'closed' | |
| id: changed | |
| uses: tj-actions/verify-changed-files@v18 | |
| with: | |
| files: | | |
| _data/citations.yaml | |
| - name: Commit updated citations to branch | |
| if: | | |
| github.event.action != 'closed' && | |
| steps.changed.outputs.files_changed == 'true' && | |
| inputs.open-pr != true | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "Update citations" | |
| - name: Open pull request with updated citations | |
| if: | | |
| github.event.action != 'closed' && | |
| steps.changed.outputs.files_changed == 'true' && | |
| inputs.open-pr == true | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| branch: citation-update | |
| title: Periodic citation update | |
| body: | | |
| To see a live preview of this PR, close (don't merge) and reopen it. | |
| outputs: | |
| changed: ${{ steps.changed.outputs.files_changed || false }} |