Description
My goal is that I want my ImageUpdateAutomation to push commits to a bump-x
branch, always overriding any old commit in the branch and keeping a single commit that updates an image tag in the main
branch directly to the newest image tag in my registry.
Image updates are working in my repo today, however when multiple image tags have been pushed since the last time the bump-x
branch was merged to main
, then my bump-x
branch will have multiple commits in it. This is annoying because I use a commit template that inserts a link to the GitHub comparison between the the commit SHA found in the newest image tag and the commit SHA found in the second newest image tag. However, the comparison links that are generated are always for the difference between this newest image tag and the image tag found in the previous commit in the bump-x
branch, not the difference between the newest image tag and the image tag currently on the main
branch. My automation uses the body of the latest commit message as the PR body, so that reviewers can easily click on comparison links and know what changes are going into production, however these comparison links are misleading today because they only show a fraction of the whole changeset.
For this reason, I'd like to find way for the image-automation-controller to always plan the commit using the main
branch and then force push that to the bump-x
branch. Reading the documentation, I thought this would be possible using the refspec
field:
In the following snippet, updates and commits will be made on the main branch locally. The commits will be then pushed using the refs/heads/main:refs/heads/auto refspec:
spec: git: checkout: ref: branch: main push: refspec: refs/heads/main:refs/heads/auto
From my reading, Flux would work on the main branch locally and then push images to the auto
branch. In my case, I used a refspec
of refs/heads/main:refs/heads/bump-x
. However, this had a very unintended result where the changeset was pushed directly to the main
branch on the remote.
How can I achieve the desired goal of always having a single commit on the bump-x
branch? If using refspecs is the way to do it, then I'm confused about the semantics of the refspec
field and how it interacts with branches that are explicitly or implicitly defined in an ImageUpdateAutomation.