I’m trying to move my org into a more gitops workflow. I was thinking a good way to do promotions between environments would be to auto sync based on PR label.
Thinking about it though, because you can apply the same label multiple times to different PRs, I can see situations where there would be conflicts. Like a PR is labeled “qa” so that its promoted to the qa env, automated testing is started, a different change is ready, the PR is labeled “qa”, and it would sync overwriting the currently deployed version in qa. I obviously don’t want this.
Is there a way to enforce only single instances of a label on a PR across a repository? Or maybe there is some kind a queue system out there that I’m not aware of?
I’m using github, argocd, and circleci.
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person’s post makes sense in another community cross post into it.
Hope you enjoy the instance!
Follow the wormhole through a path of communities !webdev@programming.dev
I would recommend you avoid relying on features of GitHub, and only use features of git. You never know when you might decide to switch repo hosting providers!
With that said, you’ve got a number of options: you can use tags or branches as “labels” to choose what’s applied to what environment, or depending on the flavor of IaC you’re using, have an entry point for each environment in your code which includes and parameterizes a common “environment” module.
Branching per environment gets to be a nightmare really quickly. I am trying to avoid that.
I am not worried about vendor lock in.
I agree. What I’m proposing is, if you go with that option, that you use a branch as a “single instance label”, pointing at commits within your main branch. Don’t use them as actual branches for additional environment-specific commits.
GitHub has an Environments feature that is probably what you’re looking for. It will tell you exactly what pr is deployed to an environment at any point in time. I would recommend automatically removing labels after the deploy is done, so that you’re not depending on reading which labels are active, instead just use the Environments.
Then don’t allow the deployed software to be overwritten while tests are running? Your test environment should be treated as a singleton. Your CI system shouldn’t be able to affect the deployment while it’s being used.
I’ve done something similar. In my case it was a startup script that did something like the following:
git fetch
for your main development branch (the one you perform the real merges to) and allpull/
refs (git does not do this by default; you’ll have to set them up for your local test repo. Note that you want to refer to the unmerged commits for these)git bisect
for this since you explicitly do not want to try commit from the middle of a PR. It might be simpler to whitelist or blacklist one commit at a time, but if you’re failing here remember that all tests are unreliable.