Last active
August 31, 2019 16:55
-
-
Save inyee786/d779f347d7fa272aed4ee8457182af35 to your computer and use it in GitHub Desktop.
travis file to build and package the helm chart
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
--- | |
language: python | |
env: | |
global: | |
- HELM_URL=https://storage.googleapis.com/kubernetes-helm | |
- HELM_TGZ=helm-v2.4.2-linux-amd64.tar.gz | |
- REPO_DIR=/home/travis/build/inyee786/test-helm | |
- YAMLLINT_VERSION=1.8.1 | |
- HARBOR_CHART_URL=https://{***domain***}/chartrepo | |
- HARBOR_PROJECT_NAME=maya | |
- CHART_FOLDER=charts | |
install: | |
# Installing Helm | |
- wget ${HELM_URL}/${HELM_TGZ} | |
- tar xzfv ${HELM_TGZ} | |
- PATH=`pwd`/linux-amd64/:$PATH | |
- helm init --client-only | |
- helm repo update | |
# helm plugin to push helm chart | |
- helm plugin install https://github.com/chartmuseum/helm-push --version v0.7.1 | |
# Installig pip deps | |
- sudo pip install yamllint=="${YAMLLINT_VERSION}" | |
script: | |
# Check charts format | |
- > | |
for dir in `ls ${REPO_DIR}/${CHART_FOLDER}`; do | |
helm lint ${REPO_DIR}/${CHART_FOLDER}/$dir | |
if [ $? != 0 ]; then | |
travis_terminate 1 | |
fi | |
done | |
# Check YAML styling | |
- yamllint -c .yamllint.yml -s .travis.yml .yamllint.yml | |
- yamllint -c .yamllint.yml -s $(find . -type f -name "Chart.yaml") | |
- yamllint -c .yamllint.yml -s $(find . -type f -name "values.yaml") | |
after_success: | |
- > | |
if [ $TRAVIS_BRANCH = 'master' ] && [ $TRAVIS_PULL_REQUEST = 'false' ]; then | |
# Temporary dir for storing new packaged charts and index files | |
BUILD_DIR=$(mktemp -d) | |
# Push temporary directory to the stack | |
pushd $BUILD_DIR | |
# Iterate over all charts are package them push it to Harbor | |
for dir in `ls ${REPO_DIR}/${CHART_FOLDER}`; do | |
helm dep update ${REPO_DIR}/${CHART_FOLDER}/$dir | |
helm package ${REPO_DIR}/${CHART_FOLDER}/$dir | |
helm push --username ${HARBOR_USERNAME} --password ${HARBOR_PASSWORD} ${REPO_DIR}/${CHART_FOLDER}/$dir ${HARBOR_CHART_URL}/maya | |
if [ $? != 0 ]; then | |
travis_terminate 1 | |
fi | |
done | |
# Pop temporary directory from the stack | |
popd | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment