From 47908cedcf6cfaae954fd3683cff054b43bdfcf9 Mon Sep 17 00:00:00 2001 From: DiheChen Date: Sat, 7 Nov 2026 22:31:11 +0800 Subject: [PATCH] ci: call CD only for tag builds --- .github/workflows/cd.yml | 15 ++++++--------- .github/workflows/ci.yml | 10 ++++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 3d2bf19..5ab60f4 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,9 +1,10 @@ name: CD on: - workflow_run: - workflows: [CI] - types: [completed] + workflow_call: + secrets: + K3S_KUBECONFIG: + required: true concurrency: group: cd-alisten @@ -15,13 +16,9 @@ permissions: jobs: deploy: - if: >- - github.event.workflow_run.conclusion == 'success' && - github.event.workflow_run.event == 'push' && - startsWith(github.event.workflow_run.head_branch, 'v') runs-on: ubuntu-latest env: - TAG: ${{ github.event.workflow_run.head_branch }} + TAG: ${{ github.ref_name }} steps: - uses: azure/setup-helm@v5 with: @@ -59,7 +56,7 @@ jobs: shell: bash env: KUBECONFIG: ${{ runner.temp }}/k3s-kubeconfig - HEAD_SHA: ${{ github.event.workflow_run.head_sha }} + HEAD_SHA: ${{ github.sha }} run: | set -euo pipefail diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5b782d8..6a85ebf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -162,3 +162,13 @@ jobs: repository="$(printf '%s' "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" printf '%s' "$GITHUB_TOKEN" | helm registry login ghcr.io --username "$GITHUB_ACTOR" --password-stdin helm push "${RUNNER_TEMP}/helm-packages/alisten-${chart_version}.tgz" "oci://ghcr.io/${repository}/charts" + + deploy: + needs: helm-release + if: github.ref_type == 'tag' + uses: ./.github/workflows/cd.yml + secrets: + K3S_KUBECONFIG: ${{ secrets.K3S_KUBECONFIG }} + permissions: + contents: read + packages: read