1. 创建或使用一个已经创建好的项目,点击Setting
image.png
2. 配置如上后,点Pages(此时看到访问地址,就说明项目已经部署好了)
image.png
3.如果有需要通过node打包,然后再将打包后的内容部署到站点的朋友,可以在本地新建文件:
image.png
* 我这里的配置是通过在【main】分支提交代码,然后自动化打包后,自动将打包后的内容提交到部署分支【deploy】
#自动化构建
name: CI
on:
push:
branches:
- main # 这里只配置了main分支,所以只有推送main分支才会触发以下任务
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }}
runs-on: ubuntu-latest
steps:
- name: Checkout ️ # 将代码拉取到虚拟机
uses: actions/checkout@v3
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
# this will use the latest Node 12 version
node-version: 16.x
- name: Install and Build # 安装依赖、打包,如果提前已打包好无需这一步
run: |
npm install
npm run build
- name: Deploy # 部署
uses: JamesIves/github-pages-deploy-action@v4.3.3
with:
branch: deploy # 部署后提交到那个分支
folder: dist # 这里填打包好的目录名称
点击Actions可以查看正在执行的自动化和历史自动化执行记录
image.png