Interview Prep/Shell Scripting/Scenarios: deployments, user management and fleet operations

In CI, after building image `api:1.4.2`, a script must update the tag in a GitOps repo and open a PR. How?

IntermediateScenarioScenarios: deployments, user management and fleet operations
Answer

Situation read → Edit YAML structurally, commit on a branch, push, and open a PR with the CLI.

What I'd do →

export NEW_TAG=1.4.2
git clone --depth 1 "https://x-access-token:${GH_TOKEN}@github.com/acme/gitops.git" && cd gitops
git switch -c "bump-api-$NEW_TAG"
yq -i '.image.tag = strenv(NEW_TAG)' apps/api/values-prod.yaml
git diff --quiet && { echo "already at $NEW_TAG"; exit 0; }
git -c user.name=ci-bot -c [email protected] commit -am "api: bump image to $NEW_TAG"
git push -u origin HEAD
gh pr create --title "api: $NEW_TAG to prod" --body "Automated bump from build $GITHUB_RUN_ID" --base main
  1. yq with strenv keeps formatting and avoids quoting bugs.
  2. git diff --quiet makes reruns harmless.

Why → GitOps requires the change to land through Git with review, not via kubectl set image.

Interview tip → Mention that tools like Argo CD Image Updater or Renovate can do this automatically.

All Shell Scripting questions Roadmap: Shell scripting (Bash)

More on Scenarios: deployments, user management and fleet operations