From 0617868cfdf557b634a2c0800e3c3d714bcc5bfa Mon Sep 17 00:00:00 2001 From: linshen <32978552+linshenkx@users.noreply.github.com> Date: Wed, 21 Jan 2026 23:05:11 +0800 Subject: [PATCH] ci: gate docker and release on tests Make docker builds and desktop releases depend on the shared test workflow to avoid duplicate runs and ensure only tested revisions ship. --- .github/workflows/docker.yml | 30 +++++------------------------- .github/workflows/release.yml | 6 ++++++ .github/workflows/test.yml | 1 + 3 files changed, 12 insertions(+), 25 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d2352a9f..19b2886a 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,11 +1,9 @@ name: Docker Build and Push on: - push: - branches: [ main, master ] - paths-ignore: - - '**.md' - - 'docs/**' + workflow_run: + workflows: [ test ] + types: [ completed ] workflow_dispatch: env: @@ -19,6 +17,7 @@ env: jobs: build: + if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'master')) }} runs-on: ubuntu-latest permissions: contents: read @@ -27,27 +26,8 @@ jobs: steps: - name: 检出代码 uses: actions/checkout@v4 - - - name: 安装 pnpm - uses: pnpm/action-setup@v2 with: - version: 10.5.2 - run_install: false - - - name: 设置 Node.js 环境 - uses: actions/setup-node@v4 - with: - node-version: '22' - cache: 'pnpm' - - - name: 安装依赖 - run: pnpm install - - - name: 运行构建 - run: pnpm build - - - name: 运行测试 - run: pnpm test + ref: ${{ github.event.workflow_run.head_sha || github.sha }} - name: 获取package.json版本号 id: version diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f3edb740..f9ae45a5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,8 +17,12 @@ env: PNPM_VERSION: '10.6.1' jobs: + test: + uses: ./.github/workflows/test.yml + # 构建 Windows 版本 build-windows: + needs: test runs-on: windows-latest steps: - name: 检出代码 @@ -152,6 +156,7 @@ jobs: # 构建 macOS 版本 build-macos: + needs: test runs-on: macos-latest steps: - name: 检出代码 @@ -278,6 +283,7 @@ jobs: # 构建 Linux 版本 build-linux: + needs: test runs-on: ubuntu-latest steps: - name: 检出代码 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e388d041..b287f701 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ on: - '**.md' - 'docs/**' workflow_dispatch: + workflow_call: jobs: test: