Check for updates of the bibliography and deploy if it changed #14146
This file contains 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
# workflow to update the bibliograhy file if it has changed. | |
name: Check for updates of the bibliography and deploy if it changed | |
on: | |
# push: | |
# branches: | |
# - main | |
schedule: | |
# every hour at minute 37 | |
- cron: "37 * * * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
permissions: | |
contents: write | |
# The following permissions are needed by the pages call if a change occured. | |
pages: write | |
id-token: write | |
jobs: | |
update_bibliography: | |
runs-on: ubuntu-latest | |
outputs: | |
bibliography_changes: ${{ env.BIBLIOGRAPHY_CHANGES }} | |
steps: | |
- name: clone | |
uses: actions/checkout@v1 | |
- name: setup python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.9" | |
- name: run zotero python client script | |
id: download_and_check | |
env: | |
ZOTERO_API_KEY: ${{ secrets.ZOTERO_API_KEY }} | |
run: | | |
pip install pyzotero==1.5.5 PyYAML==6.0 | |
python files/zotero.py | |
echo "BIBLIOGRAPHY_CHANGES=$(git diff --name-only | wc -l)" >> $GITHUB_ENV | |
- name: print_env | |
run: | | |
env | |
- name: push_if_updated | |
if: env.BIBLIOGRAPHY_CHANGES != '0' | |
run: | | |
git add _data/publications.yaml | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m "Updated bibliography" | |
- name: Push changes | |
if: env.BIBLIOGRAPHY_CHANGES != '0' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
update_pages: | |
needs: [update_bibliography] | |
if: needs.update_bibliography.outputs.bibliography_changes != '0' | |
uses: ./.github/workflows/jekyll.yml |