Skip to content

Commit 0ef17a9

Browse files
author
rain
committed
Added github actions to auto deploy to github pages. Webpack now builds to /docs
1 parent c74936b commit 0ef17a9

File tree

3 files changed

+43
-3
lines changed

3 files changed

+43
-3
lines changed

.github/workflows/deploy.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Deploy to Github Pages
2+
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
15+
steps:
16+
- name: Set up Node.js
17+
uses: actions/setup-node@
18+
with:
19+
node-version: '18'
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Build
25+
run: npm run build-prod
26+
27+
- name: Checkout
28+
run: actions/checkout@
29+
30+
- name: Deploy to Github Pages
31+
run: |
32+
# Overwrite gh-pages branch with current main branch.
33+
git checkout -B gh-pages
34+
# Build the minified file.
35+
npm run build-prod
36+
# Force ./docs to be added even though main has ./docs in its .gitignore
37+
git add -f ./docs
38+
git commit -m "Deploy to Github Pages"
39+
# Push
40+
git push -f origin gh-pages

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
.git
33

44
/node_modules/
5-
/dist/
5+
/docs/

webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const devConfig = {
4343
mode: 'development',
4444
devtool: 'eval-source-map',
4545
output: {
46-
path: path.resolve(__dirname, 'dist'),
46+
path: path.resolve(__dirname, 'docs'),
4747
filename: 'bundle.js',
4848
},
4949
devServer: {
@@ -61,7 +61,7 @@ const prodConfig = {
6161
mode: 'production',
6262
devtool: 'source-map',
6363
output: {
64-
path: path.resolve(__dirname, 'dist'),
64+
path: path.resolve(__dirname, 'docs'),
6565
filename: 'bundle.[contenthash].js',
6666
},
6767
optimization: {

0 commit comments

Comments
 (0)