1
+ name : github pages
2
+
3
+ # masterブランチにプッシュしたときjobsに記述した操作を行う
4
+ on : [push, workflow_dispatch]
5
+
6
+ permissions :
7
+ contents : read
8
+ pages : write
9
+ id-token : write
10
+
11
+ jobs :
12
+ build :
13
+ # ubuntu OS を仮想マシン上に用意する
14
+ runs-on : ubuntu-latest
15
+ steps :
16
+ - name : checkout
17
+ uses : actions/checkout@v3
18
+
19
+ - name : setup go
20
+ uses : actions/setup-go@v3
21
+ with :
22
+ go-version : ' 1.20'
23
+
24
+ # Node.js環境のセットアップを行う
25
+ - name : setup node
26
+ uses : actions/setup-node@v3
27
+ with :
28
+ node-version : 19
29
+
30
+ - name : cache dependencies for go
31
+ uses : actions/cache@v3
32
+ with :
33
+ path : |
34
+ ~/.cache/go-build
35
+ ~/go/pkg/mod
36
+ key : ${{ runner.os }}-golang-${{ hashFiles('**/go.sum') }}
37
+ restore-keys : |
38
+ ${{ runner.os }}-golang-
39
+
40
+ # npm install の際にキャッシュを使うよう設定
41
+ - name : cache dependencies for npm
42
+ uses : actions/cache@v3
43
+ with :
44
+ path : ~/.npm
45
+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
46
+ restore-keys : |
47
+ ${{ runner.os }}-node-
48
+
49
+ # package.jsonに基づき依存パッケージをインストールする
50
+ - name : install
51
+ run : npm install --frozen-lockfile
52
+
53
+ - name : build wasm
54
+ run : ./build_wasm.sh
55
+
56
+ # Next.jsアプリをビルドする
57
+ # プロジェクトルート直下に.nextディレクトリができる
58
+ - name : build
59
+ run : npm run build
60
+
61
+ # しかしGitHub Pagesの仕様として_から始まるディレクトリが見えず404となる
62
+ # つまりHTMLからJSを読み込めない
63
+ # これを回避するために.nojekyllファイルをoutディレクトリに作る
64
+ - name : add nojekyll
65
+ run : touch ./dist/.nojekyll
66
+
67
+ - name : add cname
68
+ run : cp CNAME ./dist/CNAME
69
+
70
+ # gh-pagesブランチにdistディレクトリの中身をプッシュする
71
+ # gh-pagesブランチは自動的に作成される
72
+ - name : Upload artifact
73
+ uses : actions/upload-pages-artifact@v1
74
+ with :
75
+ path : ./dist
76
+
77
+ deploy :
78
+ environment :
79
+ name : github-pages
80
+ url : ${{ steps.deployment.outputs.page_url }}
81
+ runs-on : ubuntu-latest
82
+ needs : build
83
+ steps :
84
+ - name : Deploy to GitHub Pages
85
+ id : deployment
86
+ uses : actions/deploy-pages@v1
0 commit comments