0c135ac580
The hardcoded image update for seedJob conflicts with Kustomize images transformer override. Reverting only the seed image line (line 70), keeping migrate image update and Job deletion step. Root cause: Kustomize images transformer correctly overrides ghcr.io/groombook/seed when newTag is set in UAT overlay. Overwriting the container[0].image directly in the workflow causes the old tag (2026.04.05-b090f8b) to be baked into the YAML that Flux reconciles, bypassing the Kustomize override. Fix: groombook/groombook#247 Co-Authored-By: Paperclip <noreply@paperclip.ing>
127 lines
5.2 KiB
YAML
127 lines
5.2 KiB
YAML
name: Promote to UAT
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
image_tag:
|
|
description: "Image tag to deploy to UAT (e.g. 2026.04.03-abc1234)"
|
|
required: true
|
|
type: string
|
|
|
|
jobs:
|
|
promote-to-uat:
|
|
name: Promote to groombook-uat
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
steps:
|
|
- name: Generate infra repo token
|
|
id: infra-token
|
|
uses: tibdex/github-app-token@v2
|
|
with:
|
|
app_id: ${{ vars.GH_APP_ID }}
|
|
private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}
|
|
|
|
- name: Clone groombook/infra
|
|
run: |
|
|
git clone https://x-access-token:${{ steps.infra-token.outputs.token }}@github.com/groombook/infra.git /tmp/infra
|
|
|
|
- name: Install yq
|
|
run: |
|
|
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
|
|
sudo chmod +x /usr/local/bin/yq
|
|
|
|
- name: Update UAT overlay image tags and base Job names
|
|
env:
|
|
TAG: ${{ inputs.image_tag }}
|
|
run: |
|
|
echo "Updating UAT overlay image tags to: $TAG"
|
|
cd /tmp/infra
|
|
UAT_KUST="apps/groombook/overlays/uat/kustomization.yaml"
|
|
|
|
if [ ! -f "$UAT_KUST" ]; then
|
|
echo "ERROR: UAT overlay not found at $UAT_KUST. Ensure GRO-427 has been completed."
|
|
exit 1
|
|
fi
|
|
|
|
SHORT_SHA="${TAG##*-}"
|
|
export SHORT_SHA
|
|
export TAG
|
|
|
|
yq -i '(.images[] | select(.name == "ghcr.io/groombook/api")).newTag = env(TAG)' "$UAT_KUST"
|
|
yq -i '(.images[] | select(.name == "ghcr.io/groombook/web")).newTag = env(TAG)' "$UAT_KUST"
|
|
yq -i '(.images[] | select(.name == "ghcr.io/groombook/migrate")).newTag = env(TAG)' "$UAT_KUST"
|
|
yq -i '(.images[] | select(.name == "ghcr.io/groombook/seed")).newTag = env(TAG)' "$UAT_KUST"
|
|
|
|
# Update migrate Job name to include short SHA (immutable template fix)
|
|
MIGRATE_JOB="apps/groombook/base/migrate-job.yaml"
|
|
if [ -f "$MIGRATE_JOB" ]; then
|
|
yq -i '.metadata.name = "migrate-schema-" + env(SHORT_SHA)' "$MIGRATE_JOB"
|
|
yq -i '.metadata.annotations."groombook.app/deploy-version" = env(TAG)' "$MIGRATE_JOB"
|
|
yq -i '.spec.template.spec.containers[0].image = "ghcr.io/groombook/migrate:" + env(TAG)' "$MIGRATE_JOB"
|
|
fi
|
|
|
|
# Update seed Job name to include short SHA (immutable template fix)
|
|
SEED_JOB="apps/groombook/base/seed-job.yaml"
|
|
if [ -f "$SEED_JOB" ]; then
|
|
yq -i '.metadata.name = "seed-test-data-" + env(SHORT_SHA)' "$SEED_JOB"
|
|
yq -i '.metadata.annotations."groombook.app/deploy-version" = env(TAG)' "$SEED_JOB"
|
|
fi
|
|
|
|
git -C /tmp/infra diff --stat
|
|
|
|
- name: Delete existing seed Job in UAT (immutable Job fix)
|
|
env:
|
|
TAG: ${{ inputs.image_tag }}
|
|
GH_TOKEN: ${{ steps.infra-token.outputs.token }}
|
|
run: |
|
|
cd /tmp/infra
|
|
SHORT_SHA="${TAG##*-}"
|
|
SEED_JOB_NAME="seed-test-data-${SHORT_SHA}"
|
|
|
|
echo "Deleting existing seed Job: ${SEED_JOB_NAME} in groombook-uat namespace"
|
|
|
|
gcloud container clusters get-credentials groombook-uat --zone us-central1 --project groombook-424212 2>/dev/null || \
|
|
kubectl config view --minify --raw 2>/dev/null || true
|
|
|
|
kubectl delete job/${SEED_JOB_NAME} -n groombook-uat --ignore-not-found=true 2>/dev/null || \
|
|
echo "Direct kubectl delete skipped (GitOps-only). Flux will reconcile after PR merge."
|
|
|
|
echo "Job deletion complete. Flux will reconcile the new manifest after PR merge."
|
|
|
|
- name: Create PR on groombook/infra
|
|
env:
|
|
TAG: ${{ inputs.image_tag }}
|
|
GH_TOKEN: ${{ steps.infra-token.outputs.token }}
|
|
run: |
|
|
cd /tmp/infra
|
|
git config user.name "groombook-engineer[bot]"
|
|
git config user.email "3141748+groombook-engineer[bot]@users.noreply.github.com"
|
|
git checkout -b "chore/update-uat-image-tags-${TAG}"
|
|
git add apps/groombook/overlays/uat/ apps/groombook/base/migrate-job.yaml apps/groombook/base/seed-job.yaml
|
|
git commit -m "chore: promote ${TAG} to UAT"
|
|
|
|
git push -u origin "chore/update-uat-image-tags-${TAG}"
|
|
|
|
# Create PR and merge immediately (no required checks on groombook/infra)
|
|
PR_URL=$(gh pr create \
|
|
--repo groombook/infra \
|
|
--base main \
|
|
--head "chore/update-uat-image-tags-${TAG}" \
|
|
--title "chore: promote ${TAG} to UAT" \
|
|
--body "[GRO-429](/GRO/issues/GRO-429) — UAT promotion triggered by CTO")
|
|
gh pr merge "$PR_URL" --merge
|
|
|
|
- name: Notify on failure
|
|
if: failure()
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: '## UAT Promotion Failed\n\nThe `promote-to-uat` workflow failed. Check the workflow run logs for details.\n\nCommon issues:\n- UAT overlay not found (ensure GRO-427 is complete)\n- Infra repo access token expired'
|
|
});
|