-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat(build): automate push of upgrade images #5
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c2629ce
feat(build): automate push of upgrade images
shubham14bajpai c54b868
update push sccript and added docker args
shubham14bajpai 32a8483
fix Dockerfile label
shubham14bajpai 1dc8dad
make deploy.sh executable
shubham14bajpai 189eae7
fix build command and dockerfile
shubham14bajpai 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 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 |
---|---|---|
|
@@ -41,7 +41,7 @@ script: | |
fi | ||
|
||
after_success: | ||
- # make deploy-images | ||
- make deploy-images | ||
|
||
notifications: | ||
email: | ||
|
This file contains 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 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,28 @@ | ||
#!/bin/bash | ||
# Copyright 2020 The OpenEBS Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
# Determine the arch/os we're building for | ||
ARCH=$(uname -m) | ||
|
||
if [ "${ARCH}" = "x86_64" ]; then | ||
UPGRADE_IMG="${IMAGE_ORG}/upgrade-amd64" | ||
elif [ "${ARCH}" = "aarch64" ]; then | ||
UPGRADE_IMG="${IMAGE_ORG}/upgrade-arm64" | ||
fi | ||
|
||
# tag and push all the images | ||
DIMAGE="${UPGRADE_IMG}" ./build/push |
This file contains 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,126 @@ | ||
#!/bin/bash | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use the push script from ZFS local pv. It has some optimizations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
|
||
# Copyright 2020 The OpenEBS Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -e | ||
|
||
if [ -z ${DIMAGE} ]; | ||
then | ||
echo "Error: DIMAGE is not specified"; | ||
exit 1 | ||
fi | ||
|
||
IMAGEID=$( sudo docker images -q ${DIMAGE}:ci ) | ||
echo "${DIMAGE}:ci -> $IMAGEID" | ||
if [ -z ${IMAGEID} ]; | ||
then | ||
echo "Error: unable to get IMAGEID for ${DIMAGE}:ci"; | ||
exit 1 | ||
fi | ||
|
||
# Generate a unique tag based on the commit and tag | ||
BUILD_ID=$(git describe --tags --always) | ||
|
||
# Determine the current branch | ||
CURRENT_BRANCH="" | ||
if [ -z ${TRAVIS_BRANCH} ]; | ||
then | ||
CURRENT_BRANCH=$(git branch | grep \* | cut -d ' ' -f2) | ||
else | ||
CURRENT_BRANCH=${TRAVIS_BRANCH} | ||
fi | ||
|
||
# Depending on the branch where builds are generated, | ||
# set the tag CI (fixed) and build tags. | ||
BUILD_TAG="${CURRENT_BRANCH}-${BUILD_ID}" | ||
CI_TAG="${CURRENT_BRANCH}-ci" | ||
if [ ${CURRENT_BRANCH} = "master" ]; then | ||
CI_TAG="ci" | ||
fi | ||
|
||
echo "Set the fixed ci image tag as: ${CI_TAG}" | ||
echo "Set the build/unique image tag as: ${BUILD_TAG}" | ||
|
||
function TagAndPushImage() { | ||
REPO="$1" | ||
|
||
# Trim the `v` from the TAG if it exists | ||
# Example: v1.10.0 maps to 1.10.0 | ||
# Example: 1.10.0 maps to 1.10.0 | ||
# Example: v1.10.0-custom maps to 1.10.0-custom | ||
TAG="${2#v}" | ||
|
||
# Add an option to specify a custom TAG_SUFFIX | ||
# via environment variable. Default is no tag. | ||
# Example suffix could be "-debug" of "-dev" | ||
IMAGE_URI="${REPO}:${TAG}${TAG_SUFFIX}"; | ||
|
||
sudo docker tag ${IMAGEID} ${IMAGE_URI}; | ||
echo " push ${IMAGE_URI}"; | ||
sudo docker push ${IMAGE_URI}; | ||
} | ||
|
||
|
||
if [ ! -z "${DNAME}" ] && [ ! -z "${DPASS}" ]; | ||
then | ||
sudo docker login -u "${DNAME}" -p "${DPASS}"; | ||
|
||
# Push CI tagged image - :ci or :branch-ci | ||
TagAndPushImage "${DIMAGE}" "${CI_TAG}" | ||
|
||
# Push unique tagged image - :master-<uuid> or :branch-<uuid> | ||
# This unique/build image will be pushed to corresponding ci repo. | ||
TagAndPushImage "${DIMAGE}-ci" "${BUILD_TAG}" | ||
|
||
if [ ! -z "${TRAVIS_TAG}" ] ; | ||
then | ||
# Push with different tags if tagged as a release | ||
# When github is tagged with a release, then Travis will | ||
# set the release tag in env TRAVIS_TAG | ||
TagAndPushImage "${DIMAGE}" "${TRAVIS_TAG}" | ||
TagAndPushImage "${DIMAGE}" "latest" | ||
fi; | ||
else | ||
echo "No docker credentials provided. Skip uploading ${DIMAGE} to docker hub"; | ||
fi; | ||
|
||
# Push ci image to quay.io for security scanning | ||
if [ ! -z "${QNAME}" ] && [ ! -z "${QPASS}" ]; | ||
then | ||
sudo docker login -u "${QNAME}" -p "${QPASS}" quay.io; | ||
|
||
# Push CI tagged image - :ci or :branch-ci | ||
TagAndPushImage "quay.io/${DIMAGE}" "${CI_TAG}" | ||
|
||
if [ ! -z "${TRAVIS_TAG}" ] ; | ||
then | ||
# Push with different tags if tagged as a release | ||
# When github is tagged with a release, then Travis will | ||
# set the release tag in env TRAVIS_TAG | ||
TagAndPushImage "quay.io/${DIMAGE}" "${TRAVIS_TAG}" | ||
TagAndPushImage "quay.io/${DIMAGE}" "latest" | ||
fi; | ||
else | ||
echo "No docker credentials provided. Skip uploading ${DIMAGE} to quay"; | ||
fi; | ||
|
||
#Push image to run openebs-e2e based on git commit | ||
if [ ! -z "${COMMIT}" ]; | ||
then | ||
sudo docker login -u "${GITLAB_DNAME}" -p "${GITLAB_DPASS}"; | ||
|
||
# Push COMMIT tagged image - :COMMIT | ||
TagAndPushImage "${DIMAGE}" "${COMMIT}" | ||
fi; |
This file contains 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.
Also, can you update the docker args, as used in maya upgrade.
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.
Done