Skip to content

Commit df15dd0

Browse files
committed
chore(ci): playground
1 parent 9bbec5a commit df15dd0

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

.github/workflows/playground.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: playground-deploy
2+
3+
# yamllint disable-line rule:truthy
4+
on:
5+
push:
6+
branches:
7+
- master
8+
tags:
9+
- v*.*
10+
workflow_dispatch:
11+
12+
env:
13+
nim-version: 'stable'
14+
git-url-arg: --git.url:https://github.com/${{ github.repository }} --git.commit:master
15+
deploy-dir: .gh-pages
16+
jobs:
17+
docs:
18+
runs-on: ubuntu-latest
19+
permissions:
20+
contents: write
21+
steps:
22+
- uses: actions/checkout@v4
23+
- name: Cache nimble
24+
id: cache-nimble
25+
uses: actions/cache@v4
26+
with:
27+
path: ~/.nimble
28+
key: ${{ runner.os }}-nimble
29+
- uses: jiro4989/setup-nim-action@v1
30+
with:
31+
nim-version: ${{ env.nim-version }}
32+
- name: install karax
33+
run: nimble install karax
34+
- name: buildKarax
35+
run: |
36+
nimble buildKarax -d:homepage="${{ github.event.repository.homepage }}" \
37+
-d:release --opt:size --includeJs \
38+
--htmlName=index
39+
- name: mv to deploy dir
40+
run: mv index.html ${{ env.deploy-dir }}
41+
- name: "CNAME"
42+
run: |
43+
cname=$(echo ${{ github.event.repository.homepage }} | grep -oP 'https?://\K[^/]+')
44+
prefix="play."
45+
# py: if not cname.startswith(prefix)
46+
# bash: if [[ "${cname}" != $prefix* ]]
47+
if [ ${cname##$prefix} = $cname ]; then
48+
cname="${prefix}${cname}"
49+
fi
50+
echo -n $cname > ${{ env.deploy-dir }}/CNAME
51+
# We must re-build CNAME as we use 'peaceiris/actions-gh-pages@v4',
52+
# where the old dir (including CNAME) will be purged.
53+
- name: Deploy documents
54+
uses: peaceiris/actions-gh-pages@v4
55+
with:
56+
github_token: ${{ secrets.GITHUB_TOKEN }}
57+
publish_dir: ${{ env.deploy-dir }}

0 commit comments

Comments
 (0)