![image]()
介绍
CI/CD 是持续集成(Continuous Integration,CI)、持续交付(Continuous Delivery,CD)或 持续部署(Continuous Deployment,CD)的简称
(就是全程自动化操作)
更改项目
在项目根目录下创建.github/workflows/build.yml
等 文件夹📂以及文件
![image]()
在build.yml
文件夹中直接写入以下内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| name: Auto Deploy
run-name: Deploy by @${{ github.actor }}
on: push: branches: - main
permissions: contents: read pages: write id-token: write
jobs: build: name: build-and-deploy runs-on: ubuntu-latest
steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v2 with: version: 8.3.1 - uses: actions/setup-node@v4 with: node-version: '20' cache: 'pnpm'
- name: install run: pnpm install
- name: Run Build Script run: pnpm build
- name: Upload artifact uses: actions/upload-pages-artifact@v3 with: path: ./dist deploy: environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} runs-on: ubuntu-latest needs: build steps: - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4
|
更改GitHub此项目的远程仓库配置
不知道自己项目github远程仓库地址的 可以在终端执行下面下面👇命令
![image]()
点击Settings》Pages》 Build and deployment
选择GitHub Actions即可
![image]()
收尾
执行代码上传GitHub一系列操作
1 2 3 4 5
| git add .
git commit -m '提交信息'
git push
|
之后等待此处是☑️就代表部署成功 点进去就找到地址既可以访问
![image]()
如果出现❌ 就是没通过 点进去可以看详细报错信息