-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
81 lines (81 loc) · 2.44 KB
/
action.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
name: publish-notebook
description: Build and publish a Jupyter notebook
inputs:
account_id:
description: Cloudflare account id
required: true
r2_access_key:
description: Cloudflare R2 access key
required: true
r2_secret_key:
description: Cloudflare R2 secret key
required: true
r2_bucket:
description: Cloudflare R2 bucket name
required: true
source_dir:
description: Source directory. Default is "dist"
required: false
default: dist
destination_dir:
description: Destination directory. Default is root
required: false
default: ""
prebuild:
description: Prebuild script. Runs in bash
required: false
notebooks:
description: Jupyter notebooks, separated by spaces. Default is all "*.ipynb"
required: false
default: "*.ipynb"
visibility:
description: Published notebook visibility. Values are "public" or "private". Default is "private"
required: false
default: private
hide_code:
description: Hide code blocks
required: false
default: ""
runs:
using: composite
steps:
- name: Validate inputs
shell: bash
run: |
visibility=("public", "private")
if [[ ! "${visibility[*]}" =~ "$INPUT_VISIBILITY" ]]
then
exit 1
fi
env:
INPUT_VISIBILITY: ${{ inputs.visibility }}
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version-file: pyproject.toml
cache: pip
- name: Install dependencies
shell: bash
run: pip install -r requirements.txt
- name: Run prebuild script
if: ${{ inputs.prebuild }} != ""
shell: bash
run: ${{ inputs.prebuild }}
- name: Build notebooks
shell: bash
run: jupyter nbconvert --to html --execute --output-dir $SOURCE_DIR $HIDE_CODE $NOTEBOOKS
env:
SOURCE_DIR: ${{ inputs.source_dir }}
NOTEBOOKS: ${{ inputs.notebooks }}
HIDE_CODE: ${{ inputs.hide_code != '' && '--no-input' || '' }}
- name: Upload artifacts
uses: okkema/github-action-r2@v0.1.1
with:
account_id: ${{ inputs.account_id }}
r2_access_key: ${{ inputs.r2_access_key }}
r2_secret_key: ${{ inputs.r2_secret_key }}
r2_bucket: ${{ inputs.r2_bucket }}
source_dir: ${{ inputs.source_dir }}
destination_dir: ${{ format('{0}/{1}', inputs.visibility, inputs.destination_dir) }}