-
-
Notifications
You must be signed in to change notification settings - Fork 63
143 lines (118 loc) Β· 4.36 KB
/
gh-pages.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
name: Build and Deploy GitHub Pages
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
concurrency:
# https://stackoverflow.com/a/72408109
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
env:
GITHUB_PAGES_SUBDIR_MOUNTABLE: lib/mountable
jobs:
build:
strategy:
matrix:
target: ["mountable"]
env:
# To avoid an error like "FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory".
# See https://github.com/actions/virtual-environments/issues/70#issuecomment-653886422
# The Linux VM has 7GB RAM (https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources),
# so we set the max memory size as 6.5 GiB like https://nodejs.org/api/cli.html#--max-old-space-sizesize-in-megabytes
NODE_OPTIONS: "--max-old-space-size=6656"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
## Set up Python
- uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install the latest version of uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true
cache-dependency-glob: |
**/requirements*.txt
**/uv.lock
## Set up Node environment
- uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: 'yarn'
- run: yarn install --frozen-lockfile
# We require protoc >= 3.20, but Ubuntu 22.04 - the OS that these Github
# Actions are running as of 2023.05.03 - doesn't have recent versions
# of protoc in its package repository.
# Ref: https://github.com/streamlit/streamlit/blob/1.23.1/.github/actions/make_init/action.yml#L47-L56
# So we download the precompiled binary from the release page and install it,
# following https://grpc.io/docs/protoc-installation/#install-pre-compiled-binaries-any-os
- name: Install protoc
run: |
curl -LO $PB_REL/download/v3.20.3/protoc-3.20.3-linux-x86_64.zip
unzip protoc-3.20.3-linux-x86_64.zip -d $HOME/.local
echo "$HOME/.local/bin" >> $GITHUB_PATH
env:
PB_REL: "https://github.com/protocolbuffers/protobuf/releases"
- name: Set up
run: make init
## Build and deploy @stlite/mountable
# PUBLIC_URL here is set as a relative path, which is possible to the trick introduced at https://github.com/whitphx/stlite/pull/143.
- if: matrix.target == 'mountable'
name: Set PUBLIC_URL
run: echo "PUBLIC_URL=." >> $GITHUB_ENV
- if: matrix.target == 'mountable'
name: Build @stlite/mountable
run: |
. .venv/bin/activate
make mountable
- if: matrix.target == 'mountable'
name: Upload the built files as an artifact
uses: actions/upload-artifact@v4
with:
name: stlite-mountable
path: packages/mountable/build
deploy:
needs: build
runs-on: ubuntu-latest
# Settings for GitHub pages deployment, ref: https://github.com/peaceiris/actions-gh-pages#getting-started
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: stlite-mountable
path: mountable
- name: Configure redirect
run: |
mkdir -p /tmp/website/
cat << _EOT_ > /tmp/website/_config.yml
plugins:
- jekyll-redirect-from
_EOT_
cat << _EOT_ > /tmp/website/index.html
---
redirect_to: "https://edit.share.stlite.net/"
---
_EOT_
cp /tmp/website/index.html /tmp/website/404.html
- name: Set the build artifact paths
run: |
mkdir -p /tmp/website/${GITHUB_PAGES_SUBDIR_MOUNTABLE}
cp -r ./mountable/* /tmp/website/${GITHUB_PAGES_SUBDIR_MOUNTABLE}/.
- name: Upload the website files as an artifact
uses: actions/upload-artifact@v4
if: ${{ github.ref != 'refs/heads/main' }}
with:
name: website
path: /tmp/website
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.ref == 'refs/heads/main' }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: /tmp/website
enable_jekyll: true