chore: Deploy workflow #17
This file contains 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: | |
# this is the branch where you develop your site | |
# as discussed in the publishing sources section | |
# this can change if you are using an user/organization repo | |
branches: [main] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Generate static files | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "18" | |
- run: npm i | |
- run: npm run build | |
- name: Init new repo in dist folder and commit generated files | |
run: | | |
cd ./dist | |
git init | |
git add -A | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git commit -m 'deploy' | |
- name: Force push to destination branch | |
uses: ad-m/[email protected] | |
with: | |
# Token for the repo | |
# Can be passed in using $\{{ secrets.GITHUB_TOKEN }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# Destination branch to push changes | |
branch: gh-pages | |
# Use force push to fully overwrite the destination branch | |
force: true | |
# We have to push from the folder where files were generated. | |
# Same were the new repo was initialized in the previous step | |
directory: ./dist |