-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (96 loc) · 4.15 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
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
from: GitHub Zotero CI