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

相关推荐
HelloGitHub1 小时前
《HelloGitHub》第 119 期
开源·github
冬奇Lab13 小时前
一天一个开源项目(第35篇):GitHub Store - 跨平台的 GitHub Releases 应用商店
开源·github·资讯
Jahzo16 小时前
openclaw桌面端体验--ClawX
人工智能·github
逛逛GitHub17 小时前
6个粉丝推荐的 GitHub 项目,收藏一波。
github
MaoPou21 小时前
Hello Haxe篇
github
Bigger1 天前
为什么你的 Git 提交需要签名?—— Git Commit Signing 完全指南
git·开源·github
慢慢开始吧2 天前
Redmi Note 7 Pro (Violet) 爆改满血 Linux 掌上服务器指南
github
模型时代2 天前
GitHub Codespaces存在RoguePilot漏洞,可致GitHub令牌泄露
github
webkubor2 天前
AI 时代的 robots.txt:深度解析 llms.txt 规范与项目“AI 原生化”改造实战
github
i学长的猫2 天前
obsidian md github站点
github