Skip to content

Commit b0a6db2

Browse files
authored
feat: github action (hax0r31337#1)
* feat: github action script * feat: better caching for action script * feat: cname * feat: use offical page deploy * fix: permission * fix: add hashes to filename to prevent caching
1 parent b66456f commit b0a6db2

File tree

4 files changed

+90
-3
lines changed

4 files changed

+90
-3
lines changed

.github/workflows/gh-page.yml

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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

CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pack.hanamichi.in

src/components/encrypt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export default function EncryptPage() {
3030
{/* <Spinner className="h-5 w-5" /> */}
3131
select a pack</button>
3232
<button className="bg-blue-300 hover:bg-blue-200 text-blue-900 font-bold py-2 px-4 rounded-xl transition ease-in-out duration-150"
33-
onClick={() => { window.open("https://github.com/hax0r31337") }}>
33+
onClick={() => { window.open("https://github.com/hax0r31337/pack-essentials") }}>
3434
github repository</button></div>
3535
</div>
3636
)

webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ module.exports = {
1313
},
1414
output: {
1515
path: __dirname + '/dist',
16-
filename: '[name].js',
17-
chunkFilename: '[name].js',
16+
filename: '[name].[contenthash].js',
17+
chunkFilename: '[name].[contenthash].js',
1818
publicPath: '/',
1919
},
2020
module: {

0 commit comments

Comments
 (0)