github 上的 CI/CD 的尝试

效果

步骤

  • 新建仓库
  • 设置仓库的 page
  • 新建一个 vite 的项目,改一下 vite.config.js 中的 base

工作流

在项目的根目录下新建一个 .github/workflows/ci.yml 文件,然后编辑一下内容

yml 复制代码
name: Build & Deploy Vue 3 App

on:
  push:
    branches: [main]

permissions:
  contents: write  # 👈 给写入 gh-pages 分支的权限

jobs:
  build-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 18

      - name: Install dependencies
        run: npm install

      - name: Build project
        run: npm run build

      - name: Deploy to GitHub Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: ./dist

这样的话,会监控 main 分支的改动,然后自动部署代码到 gh-pages 分支上

相关推荐
AI分享猿16 分钟前
雷池 WAF 免费版实测:企业用 Apache 搭环境,护住跨境电商平台
web安全·github·apache
whysqwhw2 小时前
kotlin-4
github
whysqwhw2 小时前
kotlin-3
github
whysqwhw2 小时前
kotlin-1
github
whysqwhw2 小时前
kotlin-2
github
CoderJia程序员甲4 小时前
GitHub 热榜项目 - 日榜(2025-11-09)
github
labview_自动化4 小时前
GitHub笔记
笔记·github
知行力4 小时前
【GitHub每日速递 20251111】PyTorch:GPU加速、动态网络,深度学习平台的不二之选!
pytorch·深度学习·github
尤利乌斯.X7 小时前
在Java中调用MATLAB函数的完整流程:从打包-jar-到服务器部署
java·服务器·python·matlab·ci/cd·jar·个人开发
逛逛GitHub8 小时前
GitHub 开源 AI 好玩神器,自动记录你的一天。
前端·github