-
Notifications
You must be signed in to change notification settings - Fork 64
Create a GitHub action for Build Image and push against main branch #563
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
Create a GitHub action for Build Image and push against main branch #563
Conversation
e5f7978
to
5a71ea9
Compare
Tested the workflow changes in fork repository https://github.com/Srihari1192/multi-cluster-app-dispatcher/actions/runs/5820949721 |
on: | ||
push: | ||
branches: | ||
- '*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- '*' | |
- 'main' |
To make sure that only push to main
branch produce new image
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used *
because of from travis CI builds noted that we are running all the branches in upstream to build and push images to the respective branch-tag https://quay.io/repository/project-codeflare/mcad-controller?tab=tags .. If its not required we can keep this to only main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@z103cb ^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to accommodate "patch" a release branch use case, @Srihari1192 will your code handle that use cases? (it seems that it would).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking what cases should we cover here:
New commit on main
branch - new dev
image published
New commit on release-<version>
branch - new dev-release-<version>
image published?
Any other case for producing non release image?
Those ^ are just my ideas, feel free to share your ideas.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sutaakar I think you have covered those. Is there any documentation how to "patch" a release? if we do that is great, if not we should create a separate issue / pr to create it.
I am Ok with restricting the branches to only the patterns you have outlined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see any specific mention about patch release in readme. I would say it follows the similar flow as a normal release:
- Create a
release-<version>
branch if not exists - Merge code changes until ready for patch release
- Trigger a release workflow, specify
release-<version>
branch as a workflow source
Ideally this should build proper image and publish correct image tag, though I haven't tried it by myself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sutaakar @z103cb I think we can put condition for assigning tag value like this. so that in case of main branch and release branch image will be pushed to the respective tag .. wdyt?
` if [[ "$GIT_BRANCH"="main" ]]; then
echo "TAG=dev" >> $GITHUB_ENV
else [[ "$GIT_BRANCH" == release-* ]]; then
echo "TAG=$GIT_BRANCH" >> $GITHUB_ENV
fi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in principle fine for me
just be careful on content of GIT_BRANCH
, AFAIK for branch it is like refs/heads/<branch name>
, see https://github.com/project-codeflare/codeflare-operator/blob/2a4731a237cf1996e6370def8c3dc7842fc2db52/.github/workflows/tag-and-build.yml#L150
Also I think that release-<branch name>
format is used for released images, so you need some other name to distinguish it (i.e. like dev-release-<branch name>
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay for release branch will update tag as dev-< release-branch>
.github/workflows/build-and-push.yml
Outdated
run: | | ||
BRANCH=$(echo ${GITHUB_REF#refs/heads/}) | ||
echo "GIT_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9._-]/-/g' )" >> $GITHUB_ENV | ||
echo "TAG=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As dev
tag is used then you don't need to retrieve it from git, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if or what value needs to be supplied below for tests/build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can assign "TAG=dev" directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5a71ea9
to
9b81207
Compare
on: | ||
push: | ||
branches: | ||
- '*' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to accommodate "patch" a release branch use case, @Srihari1192 will your code handle that use cases? (it seems that it would).
077abea
to
0134bf9
Compare
0134bf9
to
b34d120
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM
Waiting for others to chime in.
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: asm582, sutaakar The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Issue link
#559
What changes have been made
Verification steps
Checks