yarn create vite
export default defineConfig({
plugins: [react()],
build: {
outDir: 'build'
},
base: './',
})
git init
git remote add origin https://github.com/yuenci/react-gh-pages-action1.git
git branch -M main
git push -u origin main
Commit your project before your execute blow commands
git checkout -b gh-pages
# create a new branch
Go to: https://github.com/settings/tokens
# deploy.yml
name: Build and Deploy
on:
push:
branches:
- main # Set a branch to deploy
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout ποΈ
uses: actions/checkout@v3
- name: Install and Build π§ # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
run: |
npm install yarn -g
yarn
yarn build
- name: Deploy π
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build # The folder the action should deploy.
BRANCH: gh-pages # The branch the action should deploy to.
Token: ${{ secrets.TOKEN }} # This token is provided by Actions, you do not need to create your own token.
- The resources in the public file directly use the relative path, and there is no need to write "public", otherwise the compilation will be wrong.
- Don't need to configure pages, the action will automatically complete the relevant configurations.