mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-16 04:06:06 +00:00
Add travis integration to deployment
* ensure $BRANCH is always the same value (borrowed from Sonobuoy) * get gcloud SDK installed (borrowed from Sonobuoy) * use deploy step to run GCR push script (borrowed from Sonobuoy) * use gcloud's docker to do the image building/pushing * placeholders for secure values * rename $LATEST to $HIGHEST to more accurately reflect what it is Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
This commit is contained in:
+20
-1
@@ -8,4 +8,23 @@ sudo: required
|
||||
services:
|
||||
- docker
|
||||
|
||||
script: hack/ci-check.sh
|
||||
script:
|
||||
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
|
||||
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$TRAVIS_PULL_REQUEST, BRANCH=$BRANCH"
|
||||
- hack/ci-check.sh
|
||||
|
||||
# gcloud sdk is needed to upload docker images
|
||||
before_deploy:
|
||||
- if [ ! -d ${HOME}/google-cloud-sdk ]; then curl https://sdk.cloud.google.com | bash
|
||||
/dev/stdin --disable-prompts; fi
|
||||
|
||||
deploy:
|
||||
-provider: script
|
||||
skip_cleanup: true
|
||||
script: hack/gcr-push.sh
|
||||
on:
|
||||
repo: heptio/velero
|
||||
all_branches: true
|
||||
|
||||
env:
|
||||
secure: [encrypted value goes here]
|
||||
|
||||
+17
-13
@@ -1,8 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Return value is written into LATEST
|
||||
LATEST=""
|
||||
function latest_release() {
|
||||
if [[ -z "$TRAVIS" ]]; then
|
||||
echo "This script is intended to be run only on Travis." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Return value is written into HIGHEST
|
||||
HIGHEST=""
|
||||
function highest_release() {
|
||||
# Loop through the tags since pre-release versions come before the actual versions.
|
||||
# Iterate til we find the first non-pre-release
|
||||
|
||||
@@ -17,27 +22,26 @@ function latest_release() {
|
||||
if [[ "$t" == *"beta"* || "$t" == *"alpha"* || "$t" == *"rc"* ]]; then
|
||||
continue
|
||||
fi
|
||||
LATEST="$t"
|
||||
HIGHEST="$t"
|
||||
break
|
||||
done
|
||||
}
|
||||
|
||||
gcloud auth activate-service-account --key-file OUR_KEY_FILE
|
||||
unset GIT_HTTP_USER_AGENT
|
||||
|
||||
# Always publish for master
|
||||
# only publish for master or if a tag is defined
|
||||
if [ "$BRANCH" == "master" ]; then
|
||||
VERSION="$BRANCH" make all-containers all-push
|
||||
fi
|
||||
|
||||
# Publish when TRAVIS_TAG is defined.
|
||||
if [ ! -z "$TRAVIS_TAG" ]; then
|
||||
VERSION="$BRANCH" DOCKER="gcloud docker -- " make all-containers all-push
|
||||
elif [ ! -z "$TRAVIS_TAG" ]; then
|
||||
# Calculate the latest release
|
||||
latest_release
|
||||
highest_release
|
||||
|
||||
# Default to pre-release
|
||||
TAG_LATEST=false
|
||||
if [[ "$TRAVIS_TAG" == "$LATEST" ]]; then
|
||||
if [[ "$TRAVIS_TAG" == "$HIGHEST" ]]; then
|
||||
TAG_LATEST=true
|
||||
fi
|
||||
|
||||
VERSION="$TRAVIS_TAG" TAG_LATEST="$TAG_LATEST" make all-containers all-push
|
||||
VERSION="$TRAVIS_TAG" TAG_LATEST="$TAG_LATEST" DOCKER="gcloud docker -- " make all-containers all-push
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user