Add GitHub Pages deployment workflow

This commit is contained in:
Xevion
2022-11-25 02:33:45 -06:00
parent 672daceb18
commit 6ceba5fc83
2 changed files with 39 additions and 1 deletions

38
.github/workflows/deploy.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: deploy
on: [push]
jobs:
build:
name: Deploy 'grain'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: borales/actions-yarn@v3.0.0
with:
cmd: install # will run `yarn install` command
- uses: borales/actions-yarn@v3.0.0
with:
cmd: build # will run `yarn build` command
- name: Upload production-ready build files
uses: actions/upload-artifact@v2
with:
name: production-files
path: ./dist
deploy:
name: Deploy
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: production-files
path: ./dist
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist

View File

@@ -7,7 +7,7 @@ export default ({mode }) => {
process.env = {...process.env, ...loadEnv(mode, process.cwd())}; process.env = {...process.env, ...loadEnv(mode, process.cwd())};
return defineConfig({ return defineConfig({
base: process.env.NODE_ENV == 'production' ? '/grain' : '', base: process.env.NODE_ENV == 'production' ? '/grain/' : '/',
plugins: [react(), tsconfigPaths()], plugins: [react(), tsconfigPaths()],
}) })
} }