-
Notifications
You must be signed in to change notification settings - Fork 5
99 lines (89 loc) · 2.83 KB
/
build.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: build
on:
workflow_call:
inputs:
artifact_name:
description: 'The name to assign to the built book artifact.'
required: false
default: 'book-zip'
type: string
build_from_code_artifact:
description: 'Should we try to build from a previously uploaded code artifact?'
required: false
default: 'false'
type: string
workflow:
description: 'The name of the workflow that created the code artifact.'
required: false
default: 'trigger-build'
type: string
code_artifact_name:
description: 'The name of the code artifact to download.'
required: false
default: 'code-zip'
type: string
workflow_conclusion:
description: 'The conclusion of the workflow that created the code artifact.'
required: false
default: success
type: string
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- name: Checkout code
if: inputs.build_from_code_artifact != 'true'
uses: actions/checkout@v4
- name: set environment variables
run: |
echo "TODAY=$(date +%Y-%m-%d)" >> $GITHUB_ENV
- name: Download code artifact
id: get_code_artifact
if: inputs.build_from_code_artifact == 'true'
uses: dawidd6/action-download-artifact@v8
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: ${{ inputs.workflow }}
run_id: ${{ github.event.workflow_run.id }}
name: ${{ inputs.code_artifact_name }}
workflow_conclusion: ${{ inputs.workflow_conclusion }}
- name: Unzip code artifact
if: inputs.build_from_code_artifact == 'true'
run: |
unzip pr_code.zip
rm -f pr_code.zip
- name: environment setup
id: env-setup
continue-on-error: true
uses: mamba-org/setup-micromamba@v2
with:
environment-file: environment.yml
cache-environment: true
cache-environment-key: "build-${{env.TODAY}}"
- name: retry environment set up if failed
if: steps.env-setup.outcome == 'failure'
uses: mamba-org/setup-micromamba@v2
with:
download-micromamba: false
environment-file: environment.yml
cache-environment: true
cache-environment-key: "build-${{env.TODAY}}"
- name: make html
run: |
make html
- name: Zip the book
run: |
set -x
set -e
if [ -f book.zip ]; then
rm -rf book.zip
fi
zip -r book.zip ./_build/html/
- name: Upload zipped book artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name }}
path: ./book.zip