How do you promote code to environments?

When I push to the dev branch, Actions job starts and produces Docker image and modified Kustomize (Kubernetes project) manifests which I want to promote to staging branch.

In my current iteration of the workflow file, I get merge conflicts and I’m unsure on how to do this properly.

I tried the following:

  • git stash
  • git checkout staging
  • git checkout stash – .
  • git commit -am “$COMMIT_MESSAGE”
  • git push origin staging

This somewhat works but it’s messy (e.g. it doesn’t delete stuff in the staging branch, just adds to it) for obvious reasons.

Is there a proper merge/rebase command that allows me to move all edited files to the staging branch without conflicts?

1 Like

Found (actually paid for) solution that does well:

from dev branch:

git stash
git checkout staging
git merge -s recursive -X theirs dev
git checkout stash -- .
git add .
git commit -m "Update"
git push origin staging
2 Likes