我的第100篇文章,长路漫漫,唯有坚持才能成功
创建部署文件
在根目录下创建:.github/workflows/xx.yml文件
name: GitHub Actions Build and Deploy Demo
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Checkout
uses: actions/checkout@v4
- name: Install and Build
run: |
npm install
npm run-script build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
BRANCH: build
FOLDER: dist
确保构建分支存在
打开actions的权限
在仓库的设置界面:
最后上传代码即可自动构建部署