-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (66 loc) · 2.77 KB
/
generate-zot2csl-html.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
name: Generate Zotero to CSL Mappings HTML
on:
workflow_dispatch: # Manual trigger
jobs:
generate-html:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests jq
- name: Fetch the latest schema version
id: fetch_version
run: |
# Fetch the schema JSON from GitHub
curl -s https://raw.githubusercontent.com/zotero/zotero-schema/master/schema.json > schema.json
# Extract the version from the schema
SCHEMA_VERSION=$(jq -r '.version' schema.json)
# Output the version
echo "Schema version is $SCHEMA_VERSION"
# Check if the version has changed by comparing with the stored version
if [ -f last_known_version.txt ]; then
LAST_KNOWN_VERSION=$(cat last_known_version.txt)
echo "Last known version is $LAST_KNOWN_VERSION"
else
LAST_KNOWN_VERSION="none"
echo "No previous version found."
fi
# Compare versions, proceed only if different
if [ "$SCHEMA_VERSION" != "$LAST_KNOWN_VERSION" ]; then
echo "New version found, proceed with generating the HTML."
echo $SCHEMA_VERSION > last_known_version.txt
echo "version_changed=true" >> $GITHUB_ENV # Updated to use environment files
else
echo "No new version. Skip the process."
echo "version_changed=false" >> $GITHUB_ENV # Updated to use environment files
fi
- name: Generate HTML if version changed
if: env.version_changed == 'true'
run: |
python generate_zot2csl.py # Run your Python script to generate the HTML
- name: Commit and push HTML output to repository
if: env.version_changed == 'true'
run: |
# Create a directory for the output HTML file (if it doesn't exist)
mkdir -p doc
# Move the generated HTML file to the output directory
mv index.html docs/index.html
# Set up git config for commit
git config user.name "github-actions"
git config user.email "github-actions@github.com"
# Add the output file to git
git add docs/index.html
# Commit and push the changes
git commit -m "Update Zotero to CSL HTML mapping - new schema version"
git push
- name: Notify if no new version
if: env.version_changed == 'false'
run: |
echo "No new version detected, skipping HTML generation."