-
Notifications
You must be signed in to change notification settings - Fork 0
180 lines (154 loc) · 5.62 KB
/
update-publication-lists.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: Update publication lists in Asciidoc with info retrieved from Zotero
on:
repository_dispatch:
types: [update-publication-lists]
push:
branches:
- master
jobs:
update-publication-list:
runs-on: ubuntu-latest
strategy:
matrix:
zotero-collection:
- name: selection-academic
key: 'PUEWSLWI'
file-name: academic
group: '1607464'
title: '{academic-label}'
- name: selection-technical-docs
key: 'GULRY5KW'
file-name: technical
group: '1607464'
title: '{technical-label}'
- name: selection-media-articles
key: 'ZJP46GGY'
file-name: media
group: '1607464'
title: '{media-label}'
- name: selection-news
key: 'MD78TNG6'
file-name: media-mentions
group: '1607464'
title: '{media-mentions-label}'
- name: selection-interviews
key: '26V6QPYI'
file-name: interviews
group: '1607464'
title: '{interviews-label}'
- name: selection-presentations
key: '7BB2PRNI'
file-name: presentations
group: '1607464'
title: '{presentations-label}'
- name: selection-talks-video
key: 'FV7Q2L5P'
file-name: video-talks
group: '1607464'
title: '{video-talks-label}'
language: ['en', 'es', 'ca']
env:
ZOTERO_COLLECTION_NAME: ${{ matrix.zotero-collection.name }}
steps:
- name: Check out this repository
uses: actions/checkout@v2
- run: |
mkdir zotero
touch zotero/IGNORE
- name: Upload empty 'zotero' artifact
uses: actions/upload-artifact@v1
with:
name: zotero
path: zotero
- name: Download 'zotero' artifact
uses: actions/download-artifact@v1
with:
name: zotero
path: zotero
# To reduce unnecessary requests to Zotero API
- name: Check Zotero collection file existence
id: check-zotero-files-exist
uses: andstor/file-existence-action@v1
with:
files: 'zotero/${{ matrix.zotero-collection.name }}.json, zotero/${{ matrix.zotero-collection.name }}.items.json'
- name: Run HTTP request on Zotero API
if: steps.check-zotero-files-exist.outputs.files_exists == 'false'
id: zotero-request
uses: fjogeleit/http-request-action@master
with:
url: https://api.zotero.org/groups/${{ matrix.zotero-collection.group }}/collections/${{ matrix.zotero-collection.key }}/items?format=csljson
method: 'GET'
- name: Store Zotero API response in CSL JSON file
if: steps.check-zotero-files-exist.outputs.files_exists == 'false'
env:
ZOTERO_API_RESPONSE: ${{ steps.zotero-request.outputs.response }}
run: echo "$ZOTERO_API_RESPONSE" > zotero/$ZOTERO_COLLECTION_NAME.json
- name: Get items and replace "/" in ids from Zotero response, using jq
if: steps.check-zotero-files-exist.outputs.files_exists == 'false'
run: >
jq
'.items | (.[] | .id) |= ( split("/") | join("-") )'
zotero/$ZOTERO_COLLECTION_NAME.json
> zotero/$ZOTERO_COLLECTION_NAME.items.json
- name: Upload 'zotero' artifact with CSL JSON files
if: steps.check-zotero-files-exist.outputs.files_exists == 'false'
uses: actions/upload-artifact@v1
with:
name: zotero
path: zotero
- run: mkdir -p asciidoc/${{ matrix.language }}/modules/ROOT/pages
- name: Create artificial input file for Pandoc
# "nocite: '@*'" makes pandoc-citeproc generate a bibliographic entry for
# every item in bibliography file, even with no cites.
run: |
echo "---" > input.md
echo "nocite: '@*'" >> input.md
echo "..." >> input.md
- name: Use pandoc-citeproc to generate a bibliography in Asciidoc
uses: docker://pandoc/core:2.9.2
with:
args: >
input.md
--filter=pandoc-citeproc
--metadata=bibliography:"zotero/${{ matrix.zotero-collection.name }}.items.json"
--metadata=csl:apa-for-asciidoc.csl
--metadata=reference-section-title:"${{ matrix.zotero-collection.title }}"
--metadata=lang:${{ matrix.language }}
--wrap=none
--to asciidoctor
--output="asciidoc/${{ matrix.language }}/modules/ROOT/pages/${{ matrix.zotero-collection.file-name }}.adoc"
- name: Use sed to fix some problems in generated Asciidoc
# TODO: in Antora version > 2.2 adding ":page-partial:" is not neccessary
run: >
sed -i
-e 's/== /= /'
-e 's/= \\{/= {/'
-e 's/\[\[bibliography\]\]/[bibliography]/'
-e '3 i\:page-partial:'
-e '3 i\include::decidim::partial$l10n.adoc[]'
asciidoc/${{ matrix.language }}/modules/ROOT/pages/${{ matrix.zotero-collection.file-name }}.adoc
- name: Upload artifact with Asciidoc files
uses: actions/upload-artifact@master
with:
name: asciidoc
path: asciidoc
push-asciidoc-files:
runs-on: ubuntu-latest
needs: update-publication-list
steps:
- name: Check out this repository
uses: actions/checkout@v2
- name: Download 'asciidoc' artifact
uses: actions/download-artifact@v1
with:
name: asciidoc
path: .
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -m "Update publication lists" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}