Write a GitOps image-bump step: CI updates the image tag in a manifests repo.
AdvancedHands-onWrite-a-pipeline tasks
Answer
- name: Bump image in env repo
env:
GH_TOKEN: ${{ secrets.ENV_REPO_TOKEN }}
TAG: ${{ github.sha }}
run: |
git clone "https://x-access-token:${GH_TOKEN}@github.com/org/env-repo.git"
cd env-repo/apps/api/overlays/staging
kustomize edit set image "myrepo/api=myrepo/api:${TAG}"
git config user.name "ci-bot"
git config user.email "[email protected]"
git commit -am "api: deploy ${TAG::7} to staging"
for i in 1 2 3; do git pull --rebase && git push && break; sleep $((i*2)); done
Key trick → CI never talks to the cluster. Argo CD watches the env repo and syncs it. The pull-rebase-push retry loop handles concurrent pushes from other services' pipelines.
More on Write-a-pipeline tasks
Write a GitHub Actions workflow that runs tests on every PR and push to main.BeginnerWrite a workflow that builds a Docker image and pushes it to ECR using OIDC (no access keys).IntermediateWrite a matrix job that tests on Python 3.10, 3.11 and 3.12 on Linux and Windows.BeginnerWrite a declarative Jenkinsfile with build, test, Docker push and a manual approval before prod.AdvancedWrite a GitHub Actions deploy job that requires approval for production using environments.BeginnerWrite a reusable workflow and call it from another repo.Intermediate