Skip to content

Instantly share code, notes, and snippets.

@yifeiyin
Created August 4, 2021 03:31
Show Gist options
  • Save yifeiyin/12fa110b064c997c1fd7a2fe6841f2a3 to your computer and use it in GitHub Desktop.
Save yifeiyin/12fa110b064c997c1fd7a2fe6841f2a3 to your computer and use it in GitHub Desktop.
Put this file in .github/workflows/publish-gh-page.yml
name: Publish to GitHub Page
on:
push:
branches: [main]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build -- --prefix-paths
# env:
# GOOGLE_ANALYTICS_ID: ${{ secrets.GOOGLE_ANALYTICS_ID }}
- name: Push built files
run: |
git config user.email "EMAIL"
git config user.name "NAME"
cp -r public/ /tmp/gh-page-public
git fetch origin gh-pages && git checkout gh-pages
rm -rf ./*
cp -r /tmp/gh-page-public/* ./
git add -A
git commit -m "Updates"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment