From 9132a97c646248eb3e18a82ecf844e02f1506127 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= Date: Wed, 12 Mar 2025 16:44:06 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=20GitHub=20Actions?= =?UTF-8?q?=20=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy-pages.yml | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/deploy-pages.yml diff --git a/.github/workflows/deploy-pages.yml b/.github/workflows/deploy-pages.yml new file mode 100644 index 0000000..758ad6e --- /dev/null +++ b/.github/workflows/deploy-pages.yml @@ -0,0 +1,52 @@ +name: Deploy GitHub Pages + +# 触发条件 +on: + # 手动触发 + workflow_dispatch: + # 当代码推送到主分支时触发 + push: + branches: + - main + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + # 拉取代码 + - name: Checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + # 缓存 node_modules + - name: Cache node_modules + uses: actions/cache@v3 + with: + path: | + ~/.npm + node_modules + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + # 设置 Node.js 环境 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 + + # 安装依赖 + - name: Install dependencies + run: npm install + + # 构建项目 + - name: Build + run: npm run build + + # 部署到 GitHub Pages + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist # 这里的 dist 是构建后的文件目录,根据实际情况修改 \ No newline at end of file