From 5064d43bdb8d5665d1cf55be6b2b1c431c9c3639 Mon Sep 17 00:00:00 2001 From: hxuanyu <2252193204@qq.com> Date: Fri, 27 Jun 2025 16:21:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20GitHub=20Pages=20=E9=83=A8?= =?UTF-8?q?=E7=BD=B2=E5=B7=A5=E4=BD=9C=E6=B5=81=EF=BC=8C=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9E=84=E5=BB=BA=E5=92=8C=E5=8F=91=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 61 ++++++++++++++++++++++++++++++++++++ vite.config.ts | 1 + 2 files changed, 62 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c951469 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,61 @@ +name: Deploy to GitHub Pages + +on: + # 当推送到main分支时触发 + push: + branches: [ main ] + + # 允许手动触发工作流 + workflow_dispatch: + +# 设置GITHUB_TOKEN的权限以允许部署到GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# 只允许一个并发部署,跳过正在进行的运行之间的队列 +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + # 构建作业 + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Setup Pages + uses: actions/configure-pages@v4 + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # 上传dist目录 + 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 diff --git a/vite.config.ts b/vite.config.ts index bbcf80c..7153822 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -4,4 +4,5 @@ import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], + base: process.env.NODE_ENV === 'production' ? '/obs-overlay-widget/' : '/', })