Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker image with git sha only for pushes on main branch #155

Merged
merged 1 commit into from
Sep 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion .github/workflows/build-images-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ on:
type: string

env:
IMG_TAGS: ${{ github.sha }} ${{ inputs.operatorTag }}
IMG_TAGS: ${{ inputs.operatorTag }}
VERSION: ${{ inputs.operatorVersion }}
IMG_REGISTRY_HOST: quay.io
IMG_REGISTRY_ORG: kuadrant
Expand All @@ -65,6 +65,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Add git sha tag for the main branch
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-git-sha-tag
run: |
echo "IMG_TAGS=${{ github.sha }} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
Copy link
Contributor

@guicassolato guicassolato Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand Build images for main branch will trigger a build when commits are pushed to main. By not specifying operatorTag, these builds will be tagged latest (default) and <commit-sha> (added in this line).

Build images for dev branches will NOT trigger a build for main due to the if condition added (to make sure only pushes to feature branches will do it). However, Schedule build with latest image SHA versions will trigger another build, and by specifying operatorTag = <commit-sha>, these images will have the <commit-sha> tag only (redundantly added here) and will separate from latest (previously built, on a different manifest).

Q: Do we need to keep Schedule build with latest image SHA versions? Is it because it specifies limitadorVersion? If we are to keep it, can we please remove the operatorTag param there (so it assumes latest by default)? In this case, would we still need Build images for main branch?

Copy link
Contributor

@guicassolato guicassolato Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we probably want to keep Build images for main branch and get rid of Schedule build with latest image SHA versions. Maybe add limitadorVersion to the former?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was about to delete the scheduled build with the latest image with the git sha tag. But then I realized that this build is actually the correct one. The build triggered from push to main is not correct.

We need to fix this in a following up PR

That's good enough, @guicassolato ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IDK. I don't really like that main is built twice today. I would get rid of the scheduled one right away and add limitadorVersion: ${{ vars.LIMITADOR_SHA }} to the build main one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Too soon. I see the problem with that now... When the operand changes, nothing will rebuild the operator with the updated SHA, right? Damn!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So add limitadorVersion: ${{ vars.LIMITADOR_SHA }} to build main and remove this line but keep both workflows? main will build twice but at least both tags will be added and linked every time. Right?

Copy link
Contributor Author

@eguzki eguzki Sep 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh! Too soon. I see the problem with that now... When the operand changes, nothing will rebuild the operator with the updated SHA, right? Damn!

Right.

The other option is to trigger build on the operator project when the operand gets a new build. But I rather prefer the nightly build approach instead. To avoid too many operator builds in the same day when the operand changes many times in the same day.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to fix that in another PR

- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
Expand Down Expand Up @@ -117,6 +122,11 @@ jobs:
LIMITADOR_VERSION=${{ inputs.limitadorVersion }} \
REPLACES_VERSION=${{ inputs.replacesVersion }} \
CHANNELS=${{ inputs.channels }}
- name: Add git sha tag for the main branch
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-git-sha-tag
run: |
echo "IMG_TAGS=${{ github.sha }} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
Expand Down Expand Up @@ -163,6 +173,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y qemu-user-static
- name: Add git sha tag for the main branch
if: ${{ github.ref_name == env.MAIN_BRANCH_NAME }}
id: add-git-sha-tag
run: |
echo "IMG_TAGS=${{ github.sha }} ${{ env.IMG_TAGS }}" >> $GITHUB_ENV
- name: Build Image
id: build-image
uses: redhat-actions/buildah-build@v2
Expand Down
Loading