-
Notifications
You must be signed in to change notification settings - Fork 0
206 lines (194 loc) · 6.21 KB
/
book-production.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
name: book-production
run-name: book-production for ${{ inputs.doi }}
on:
workflow_dispatch:
inputs:
doi:
description: 'DOI of book (last four digits only)'
required: true
type: number
has_pdf:
description: 'Run PDF workflow'
default: true
required: true
type: boolean
has_epub:
description: 'Run EPUB workflow'
default: true
required: true
type: boolean
env:
WORK_DIR: /ebook_automation/
OUT_DIR: /ebook_automation/output/
jobs:
download-pdf:
runs-on: ubuntu-latest
if: ${{ inputs.has_pdf }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy PDF from S3
run: |
aws s3 cp ${{ secrets.S3_URL }}obp.${{ inputs.doi }}.pdf .
- name: Save PDF
uses: actions/upload-artifact@v4
with:
name: original-pdf
path: obp.${{ inputs.doi }}.pdf
retention-days: 10
if-no-files-found: error
overwrite: true
download-epub:
runs-on: ubuntu-latest
if: ${{ inputs.has_epub }}
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy EPUB from S3
run: |
aws s3 cp ${{ secrets.S3_URL }}obp.${{ inputs.doi }}.epub .
- name: Save EPUB
uses: actions/upload-artifact@v4
with:
name: original-epub
path: obp.${{ inputs.doi }}.epub
retention-days: 10
if-no-files-found: error
overwrite: true
archive-pdf-urls:
needs: download-pdf
runs-on: ubuntu-latest
steps:
- name: Install archive-pdf-urls
# https://github.com/thoth-pub/archive-pdf-urls
run: cargo install archive-pdf-urls
- name: Retrieve PDF
uses: actions/download-artifact@v4
with:
name: original-pdf
- name: Run archive-pdf-urls Rust script
run: archive-pdf-urls obp.${{ inputs.doi }}.pdf --exclude https://doi.org/10.11647/OBP.${{ inputs.doi }}\*
chapter-splitter:
needs: download-pdf
runs-on: ubuntu-latest
container:
image: openbookpublishers/chapter-splitter
steps:
- name: Retrieve Data
uses: actions/download-artifact@v4
with:
name: original-pdf
path: ${{ env.WORK_DIR }}
- name: Create Output Folder
run: mkdir ${{ env.OUT_DIR }}
- name: Run Python Command
working-directory: ${{ env.WORK_DIR }}
run: |
python3 main.py \
--input-file obp.${{ inputs.doi }}.pdf \
--output-folder ${{ env.OUT_DIR }} \
--write-urls \
10.11647/obp.${{ inputs.doi }}
env:
THOTH_EMAIL: ${{ secrets.THOTH_EMAIL }}
THOTH_PWD: ${{ secrets.THOTH_PASSWORD }}
- name: Save Data
uses: actions/upload-artifact@v4
with:
name: chapters
path: ${{ env.OUT_DIR }}
retention-days: 1
if-no-files-found: error
overwrite: true
epublius:
needs: download-epub
runs-on: ubuntu-latest
container:
image: openbookpublishers/epublius
steps:
- name: Retrieve Data
uses: actions/download-artifact@v4
with:
name: original-epub
path: ${{ env.WORK_DIR }}
- name: Create Output Folder
run: mkdir ${{ env.OUT_DIR }}
- name: Run Python Command
working-directory: ${{ env.WORK_DIR }}
run: |
./thoth_wrapper.py obp.${{ inputs.doi }}.epub \
--doi 10.11647/obp.${{ inputs.doi }}
env:
MATHJAX: 'False'
PRIVACYPOLICY_URL: 'https://www.openbookpublishers.com/policies/privacy/'
OUTDIR: ${{ env.OUT_DIR }}
THOTH_EMAIL: ${{ secrets.THOTH_EMAIL }}
THOTH_PWD: ${{ secrets.THOTH_PASSWORD }}
- name: Save Data
uses: actions/upload-artifact@v4
with:
name: HTML
path: ${{ env.OUT_DIR }}/10.11647/
retention-days: 1
if-no-files-found: error
overwrite: true
upload-chapters:
needs: chapter-splitter
runs-on: ubuntu-latest
env:
CHAPTERS_DIR: ./chapters
steps:
- name: Retrieve Data
uses: actions/download-artifact@v4
with:
name: chapters
path: ${{ env.CHAPTERS_DIR }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy Chapter PDFs to S3
run: |
aws s3 cp ${{ env.CHAPTERS_DIR }} ${{ secrets.S3_URL }} --recursive
upload-html:
needs: epublius
runs-on: ubuntu-latest
steps:
- name: Retrieve Data
uses: actions/download-artifact@v4
with:
name: HTML
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy HTML Edition to S3
run: |
aws s3 cp ./obp.${{ inputs.doi }}/ ${{ secrets.S3_URL }}obp.${{ inputs.doi }}/ --recursive
cit-ex-obp-loader:
needs: upload-html
runs-on: ubuntu-latest
container:
image: openbookpublishers/cit-ex-obp-loader
env:
WORK_DIR: /home/obp/cit-ex/
steps:
- name: Run Python Command
working-directory: ${{ env.WORK_DIR }}
run: |
python3 obp-loader.py 10.11647/obp.${{ inputs.doi }}
env:
THOTH_EMAIL: ${{ secrets.THOTH_EMAIL }}
THOTH_PWD: ${{ secrets.THOTH_PASSWORD }}