Deploy to GitHub Pages #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to GitHub Pages | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: npm install | |
- name: Build project | |
run: npm run build | |
- name: Checkout gh-pages branch | |
run: | | |
git fetch origin gh-pages | |
git checkout gh-pages || git checkout -b gh-pages | |
- name: Copy build files | |
run: cp -r public/* . | |
- name: Deploy to GitHub Pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git add . | |
git commit -m "Deploy to GitHub Pages" || echo "No changes to commit" | |
git push origin gh-pages |