CI Zotero Backup #964
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
name: CI Zotero Backup | |
on: | |
push: | |
branches: [master] | |
schedule: | |
# More info under: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#scheduled-events | |
# Setup: Monday to Friday at 5:30am UTC | |
- cron: '30 5 * * *' | |
env: | |
ZB_SEARCH_PREFIX_URI: groups/2480461 | |
ZB_OUT_DIR: "data/ag-gipp" | |
ZB_FILE: "data/ag-gipp/latest.json" | |
ZB_VERSION_FILE: "data/ag-gipp/.last-modified-version" | |
ZB_PYTHON: python | |
ZB_LOG_LEVEL: INFO | |
PYTHONIOENCODING: "utf-8" | |
ZB_SEARCH_TAG: "" | |
jobs: | |
backup: | |
name: Backup Zotero | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Zotero backup repo | |
uses: actions/checkout@v2 | |
with: | |
submodules: 'false' | |
- name: Checkout private data submodule | |
env: | |
DATA_SSH_KEY: ${{ secrets.BACKUP_DATA_ZOTERO_REPO_KEY }} | |
run: | | |
mkdir -p $HOME/.ssh | |
echo "$DATA_SSH_KEY" > $HOME/.ssh/data_deploy.key | |
chmod 600 $HOME/.ssh/data_deploy.key | |
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/data_deploy.key" | |
git submodule update --init --recursive --remote --rebase | |
- name: Setup Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.7' | |
- name: Install python requirements | |
run: pip install -r requirements.txt | |
- name: Download Zotero data | |
run: python ./download.py | |
env: | |
ZB_API_KEY: ${{ secrets.ZB_API_KEY }} | |
- name: Check data consistency | |
run: python ./consistency-report.py "$ZB_FILE" > "$ZB_OUT_DIR/report.md" | |
- name: Extract decentralized open science publist | |
run: python ./extract-bibtex.py "$ZB_FILE" decentralized_open_science > "bib/decentralized_open_science.bib" | |
- name: Create decentralized open science publist | |
run: | | |
cd bib | |
./support/pubAll.sh decentralized_open_science | |
cd .. | |
- name: Extract moritz publist | |
run: python ./extract-bibtex.py "$ZB_FILE" \!ms_author > "bib/list.bib" | |
- name: Create moritz publist | |
run: | | |
cd bib | |
./support/pubAll.sh list | |
cd .. | |
- name: Push updates | |
# Environment variables do not survive steps. The exported GIT_SSH_COMMAND | |
# from above does not exist here. Hence, we first update the link and after that | |
# set the GIT_SSH_COMMAND again | |
run: | | |
git config --global user.name 'BinBot' | |
git config --global user.email '[email protected]' | |
cd data | |
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/data_deploy.key" | |
git add -A | |
git commit -am "[skip ci] Update backup data (build ${GITHUB_RUN_ID})" | |
git push origin HEAD:master | |
cd .. | |
cd bib | |
git add -A | |
git commit -am "[skip ci] Update bib data (build ${GITHUB_RUN_ID})" || true | |
git push origin HEAD:master || true | |
cd .. | |
unset GIT_SSH_COMMAND | |
git add -A | |
git commit -am "[skip ci] Update link to backup data (build ${GITHUB_RUN_ID})" | |
git push | |
- name: Notify Collaborators on Failure | |
if: hashFiles('$ZB_OUT_DIR/report.md') != '' | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: ${{ secrets.NOTIF_MAIL_SERVER }} | |
server_port: 465 | |
username: ${{ secrets.NOTIF_MAIL_USER }} | |
password: ${{ secrets.NOTIF_MAIL_PW }} | |
subject: "GitHub CI Zotero Backup Report ${{ job.status }}" | |
html_body: '<p>The GitHub workflow ${{ github.workflow }} in ${{ github.repository }} finished on <b>${{ job.status }}</b></p><p>Further details can be accessed at the <a href="https://github.com/ag-gipp/zotero-backup/actions">GitHub CI overview page</a>.</p><p><b>Detailed Reasons:</b><br>Event causing the failure: ${{ github.event_name }}<br>Author: ${{ github.event.commits[0].author.name }}<br>E-Mail: ${{ github.event.commits[0].author.email }}<br>Commit Message: ${{ github.event.commits[0].message }}<br>Commit ID: <a href="${{ github.event.commits[0].url }}">${{ github.event.commits[0].id }}</a><br></p>' | |
# recipients' addresses split by comma | |
to: [email protected] | |
from: GitHub Zotero CI |