-
Notifications
You must be signed in to change notification settings - Fork 1
141 lines (136 loc) · 5.28 KB
/
manubot.yaml
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
name: Manubot
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
BUILD_PDF:
type: boolean
description: generate PDF output
default: true
BUILD_DOCX:
type: boolean
description: generate DOCX output
default: false
BUILD_LATEX:
type: boolean
description: generate LaTeX output
default: false
SPELLCHECK:
type: boolean
description: Check spelling
default: true
MANUBOT_USE_DOCKER:
type: boolean
description: Use Docker to generate PDF
default: true
concurrency:
# only one run per branch at a time
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
manubot:
name: Manubot
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
env:
BUILD_DOCX: true
GITHUB_PULL_REQUEST_SHA: ${{ github.event.pull_request.head.sha }}
# Set SPELLCHECK to true/false for whether to check spelling in this action.
# For workflow dispatch jobs, this SPELLCHECK setting will be overridden by the user input.
SPELLCHECK: true
defaults:
run:
shell: bash --login {0}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
# fetch entire commit history to support get_rootstock_commit
fetch-depth: 0
- name: Set Environment Variables (Workflow Dispatch)
if: github.event_name == 'workflow_dispatch'
run: |
echo "BUILD_PDF=${{ github.event.inputs.BUILD_PDF }}" >> $GITHUB_ENV
echo "BUILD_DOCX=${{ github.event.inputs.BUILD_DOCX }}" >> $GITHUB_ENV
echo "BUILD_LATEX=${{ github.event.inputs.BUILD_LATEX }}" >> $GITHUB_ENV
echo "SPELLCHECK=${{ github.event.inputs.SPELLCHECK }}" >> $GITHUB_ENV
echo "MANUBOT_USE_DOCKER=${{ github.event.inputs.MANUBOT_USE_DOCKER }}" >> $GITHUB_ENV
- name: Set Environment Variables
run: |
TRIGGERING_SHA=${GITHUB_PULL_REQUEST_SHA:-$GITHUB_SHA}
echo "TRIGGERING_SHA_7=${TRIGGERING_SHA::7}" >> $GITHUB_ENV
echo "TRIGGERING_SHA: $TRIGGERING_SHA"
DEFAULT_BRANCH=${{ github.event.repository.default_branch }}
echo "DEFAULT_BRANCH=${DEFAULT_BRANCH}" >> $GITHUB_ENV
echo "DEFAULT_BRANCH_REF=refs/heads/$DEFAULT_BRANCH" >> $GITHUB_ENV
echo "DEFAULT_BRANCH=$DEFAULT_BRANCH"
- name: Cache
uses: actions/cache@v4
with:
path: ci/cache
key: ci-cache-${{ github.ref }}
restore-keys: |
ci-cache-${{ env.DEFAULT_BRANCH_REF }}
- name: Install Environment
uses: conda-incubator/setup-miniconda@v3
with:
activate-environment: manubot
environment-file: build/environment.yml
auto-activate-base: false
miniforge-variant: Mambaforge
miniforge-version: "latest"
use-mamba: true
- name: Install Spellcheck
if: env.SPELLCHECK == 'true'
run: bash ci/install-spellcheck.sh
- name: Build Manuscript
run: bash build/build.sh
- name: Upload Artifacts
uses: actions/upload-artifact@v4
id: artifact-upload-step
with:
name: manuscript-${{ github.run_id }}-${{ env.TRIGGERING_SHA_7 }}
path: output
- name: Deploy Manuscript
if: github.ref == env.DEFAULT_BRANCH_REF && github.event_name != 'pull_request' && !github.event.repository.fork
env:
MANUBOT_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MANUBOT_SSH_PRIVATE_KEY: ${{ secrets.MANUBOT_SSH_PRIVATE_KEY }}
CI_BUILD_WEB_URL: https://github.com/${{ github.repository }}/commit/${{ github.sha }}/checks
CI_JOB_WEB_URL: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: bash ci/deploy.sh
- name: Count spelling errors
run: |
# count the number of spelling errors using the spelling-error-locations.txt file
# this file does not include preamble or author list spelling errors
if [ -s output/spelling-error-locations.txt ]; then
echo "SPELLING_ERRORS=$(wc -l < output/spelling-error-locations.txt)" >> $GITHUB_ENV
else
echo "SPELLING_ERRORS=0" >> $GITHUB_ENV
fi
- name: Post artifact comment to PR
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
**Click the link below to download the manuscript build as a ZIP file.**
This build is associated with commit ${{ env.TRIGGERING_SHA_7 }}.
[Manuscript build](${{ steps.artifact-upload-step.outputs.artifact-url }})
**There were ${{ env.SPELLING_ERRORS }} spelling errors.**
Check the build link above for details.
- name: Fail for spelling errors in manual builds
if: github.event_name == 'workflow_dispatch' && env.SPELLCHECK == 'true'
run: |
if [ $SPELLING_ERRORS ]; then
echo "Spelling errors (some may be in the author list):"
cat output/spelling-errors.txt
exit 1
fi