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 分支上

相关推荐
九狼1 天前
Flutter URL Scheme 跨平台跳转
人工智能·flutter·github
逛逛GitHub1 天前
4 个热门的 GitHub 开源项目
github
程序员鱼皮1 天前
GitHub 关注突破 2w,我总结了 10 个涨星涨粉技巧!
前端·后端·github
HelloGitHub2 天前
《HelloGitHub》第 119 期
开源·github
冬奇Lab2 天前
一天一个开源项目(第35篇):GitHub Store - 跨平台的 GitHub Releases 应用商店
开源·github·资讯
Jahzo2 天前
openclaw桌面端体验--ClawX
人工智能·github
逛逛GitHub2 天前
6个粉丝推荐的 GitHub 项目,收藏一波。
github
MaoPou2 天前
Hello Haxe篇
github