-
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
Merged
openshift-merge-robot
merged 1 commit into
project-codeflare:main
from
Srihari1192:build-push-559
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
name: Build and Push dev MCAD image into Quay | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: checkout code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set latest tag and Branch name | ||
run: | | ||
BRANCH=$(echo ${GITHUB_REF#refs/heads/}) | ||
echo "GIT_BRANCH=$(echo "$BRANCH" | sed 's/[^A-Za-z0-9._-]/-/g' )" >> $GITHUB_ENV | ||
if [[ "$BRANCH" == "main" ]]; then | ||
echo "TAG=dev" >> $GITHUB_ENV | ||
elif [[ "$BRANCH" == release-* ]]; then | ||
echo "TAG=dev-$BRANCH" >> $GITHUB_ENV | ||
else | ||
LATEST_TAG=$(git describe --abbrev=0 --tags) | ||
echo "TAG=$BRANCH-$LATEST_TAG" >> $GITHUB_ENV | ||
fi | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: 1.19.10 | ||
|
||
- name: Build | ||
run: | ||
make mcad-controller | ||
|
||
- name: Run Unit tests | ||
run: make run-test | ||
|
||
- name: Build Image | ||
run: | | ||
make images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }} | ||
|
||
- name: Push Image | ||
run: | | ||
make push-images -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }} quay_repository=quay.io/project-codeflare quay_id=${{ secrets.QUAY_ID }} quay_token=${{ secrets.QUAY_TOKEN }} | ||
|
||
- name: Run E2E tests | ||
run: | | ||
make run-e2e -e GIT_BRANCH=${{ env.GIT_BRANCH }} TAG=${{ env.TAG }} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
To make sure that only push to
main
branch produce new imageThere 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 onlymain
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 - newdev
image publishedNew commit on
release-<version>
branch - newdev-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.
Uh oh!
There was an error while loading. Please reload this page.
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:
release-<version>
branch if not existsrelease-<version>
branch as a workflow sourceIdeally this should build proper image and publish correct image tag, though I haven't tried it by myself.
Uh oh!
There was an error while loading. Please reload this page.
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?
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 likerefs/heads/<branch name>
, see https://github.com/project-codeflare/codeflare-operator/blob/2a4731a237cf1996e6370def8c3dc7842fc2db52/.github/workflows/tag-and-build.yml#L150Also I think that
release-<branch name>
format is used for released images, so you need some other name to distinguish it (i.e. likedev-release-<branch name>
)Uh oh!
There was an error while loading. Please reload this page.
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>