From eaa319c677306f786b072abe487d36bc30d954fc Mon Sep 17 00:00:00 2001 From: Andrey Ilin Date: Thu, 12 Nov 2026 13:27:16 +0100 Subject: [PATCH 1/2] feat: allow staging GitOps ref override --- .github/workflows/kubernetes.yaml | 16 +++++++++++++++- README.md | 24 ++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/.github/workflows/kubernetes.yaml b/.github/workflows/kubernetes.yaml index afd5bbb..db59259 100644 --- a/.github/workflows/kubernetes.yaml +++ b/.github/workflows/kubernetes.yaml @@ -32,6 +32,11 @@ on: description: The repository within Github that holds the version file to deploy via GitOps default: parcelLab/deployment type: string + stagingDeploymentRepoRef: + required: false + description: Git ref or SHA for staging GitOps configuration (requires pushToEnvTag). Ignored outside staging; empty uses main. + default: "" + type: string imageTargets: required: false description: If provided, sets targets for as many image builds as targets specified. When bakeFile is provided, these are Docker Buildx Bake targets. @@ -169,6 +174,15 @@ jobs: channel-id: ${{ steps.vars.outputs.channel-id }} version: ${{ steps.vars.outputs.version }} steps: + - name: Require an environment tag for staging configuration overrides + if: (github.event.deployment.payload.env || inputs.env) == 'staging' && inputs.stagingDeploymentRepoRef != '' + env: + PUSH_TO_ENV_TAG: ${{ github.event.deployment.payload.pushToEnvTag || inputs.pushToEnvTag }} + run: | + if [ "$PUSH_TO_ENV_TAG" != "true" ]; then + echo "::error::stagingDeploymentRepoRef requires pushToEnvTag to avoid pushing branch configuration to main" + exit 1 + fi - name: Check if 'env' input is provided run: | DEPLOY_ENV="${{ github.event.deployment.payload.env || inputs.env }}" @@ -247,7 +261,7 @@ jobs: repository: ${{ inputs.deploymentRepoURL }} path: remote token: ${{ secrets.repoAccessToken }} - ref: ${{ github.event.deployment.payload.rebuild != null && (github.event.deployment.payload.pushToEnvTag == 'true' || inputs.pushToEnvTag) && 'refs/tags/prod' || 'main' }} + ref: ${{ (github.event.deployment.payload.env || inputs.env) == 'staging' && inputs.stagingDeploymentRepoRef || (github.event.deployment.payload.rebuild != null && (github.event.deployment.payload.pushToEnvTag == 'true' || inputs.pushToEnvTag) && 'refs/tags/prod' || 'main') }} - name: Refuse to replace a newer production release if: github.event.deployment.payload.rebuild != null uses: mikefarah/yq@v4.53.2 diff --git a/README.md b/README.md index ea0fd11..6ed38e0 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,30 @@ the release tag or commit in `.chart/prod/values.yaml` (at the `prod` tag with ` with fresh base images and no cache. It deploys as `rebuild-.-` and is skipped if another release reaches production first. +## Staging configuration from a feature branch + +`kubernetes.yaml` accepts `stagingDeploymentRepoRef` to select the GitOps configuration +revision for staging. When the deployment repository is the application repository, +pass the deployment SHA to use the chart and values from the same commit as the code: + +```yaml +uses: parcelLab/ci/.github/workflows/kubernetes.yaml@v9 +with: + deploymentRepoURL: parcelLab/backend + deploymentRepoPath: .chart/${{ github.event.deployment.payload.env }} + stagingDeploymentRepoRef: ${{ github.event.deployment.sha }} +``` + +This requires `pushToEnvTag: true` in the deployment payload or Kubernetes workflow +inputs. The workflow updates the image version on top of the selected revision and +pushes the `staging` tag, which ArgoCD must track. It fails before building if tag +publishing is disabled, to prevent pushing feature branch configuration to `main`. +The ref must exist in `deploymentRepoURL`; it does not select a revision in a +separate infrastructure repository or change the application build revision. + +An empty ref keeps staging configuration on `main`. The input is ignored for all +other environments, including production and weekly production rebuilds. + ## Contributing [Contribution guidelines](CONTRIBUTING.md) From d7c9faf12829503dccd1256fed572b46df5dabef Mon Sep 17 00:00:00 2001 From: Andrey Ilin Date: Thu, 12 Nov 2026 13:41:57 +0100 Subject: [PATCH 2/2] fix: parse deployment push flag correctly --- .github/workflows/kubernetes.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/kubernetes.yaml b/.github/workflows/kubernetes.yaml index db59259..3ae4d35 100644 --- a/.github/workflows/kubernetes.yaml +++ b/.github/workflows/kubernetes.yaml @@ -177,7 +177,7 @@ jobs: - name: Require an environment tag for staging configuration overrides if: (github.event.deployment.payload.env || inputs.env) == 'staging' && inputs.stagingDeploymentRepoRef != '' env: - PUSH_TO_ENV_TAG: ${{ github.event.deployment.payload.pushToEnvTag || inputs.pushToEnvTag }} + PUSH_TO_ENV_TAG: ${{ format('{0}', github.event.deployment.payload.pushToEnvTag) == 'true' || inputs.pushToEnvTag }} run: | if [ "$PUSH_TO_ENV_TAG" != "true" ]; then echo "::error::stagingDeploymentRepoRef requires pushToEnvTag to avoid pushing branch configuration to main" @@ -292,7 +292,7 @@ jobs: GIT_USER_NAME: parcellab-dev-bot ENV: ${{ github.event.deployment.payload.env || inputs.env }} VERSION: ${{ needs.initialize.outputs.version }} - PUSH_TO_ENV_TAG: ${{ github.event.deployment.payload.pushToEnvTag || inputs.pushToEnvTag }} + PUSH_TO_ENV_TAG: ${{ format('{0}', github.event.deployment.payload.pushToEnvTag) == 'true' || inputs.pushToEnvTag }} - if: success() && github.event_name == 'deployment' name: Successful ${{ github.event.deployment.payload.name || inputs.appName }} deployment uses: chrnorm/deployment-status@v2