-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy path.travis.yml
106 lines (93 loc) · 3.9 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
language: python
env:
global:
- TARGET_BR=master
- REPO_DIR=/home/travis/build/sitewhere/sitewhere-k8s
- YAMLLINT_VERSION=1.25.0
- DESIRED_VERSION="v3.5.0"
- HELM_URL=https://storage.googleapis.com/kubernetes-helm
- HELM_TGZ=helm-v2.4.1-linux-amd64.tar.gz
- TARGET_REPO_URL=https://github.com/sitewhere/sitewhere.github.io.git
- TARGET_BR=master
- REPO_DIR=/home/travis/build/sitewhere/sitewhere-k8s
- GH_URL=https://sitewhere.io/helm-charts
- YAMLLINT_VERSION=1.8.1
- secure: s6xy2omQv2PyXPAE5p7vxYgbKaZDLd+mXMAUz42zY6FAWvInLI9qxJ2ghPuuvvMe2Fwdrc9p+ubzfKB5fqpNrt8LctIrgXmEWkMI9kvZ/7L/e8GvSsXwglfE9OVLhMVIAWzhZlqClFVO1dKz5LEj+KnYlSqSRkkLkKvWIgmiX279eaU8FTksMQT6oFsD+VoEyj9vhNPBGedh+aXvdkE9hLEQJKD98pbszNKPeSau1H935N1ENCUjDyY5RPVZjp1eL1FkiklZ++ZvksBB4JlXbvDB9Af7zcvttdSZ4W0Ck/AplpGCszhbx/FJ9EdwEnA4cMVJjzL0FfTwHX5CJudM2R+o/kendsmFVP6PwrhXJwNPZzBLRylZcSzIvEhn8JWaDSZrY5OMGJGwT4pELVD1Qn+m5zxQ8O9VNkz4ftEt8+JAlTaeap46TeubBgTvdUWIdU+8zlhx/BZyhzuDNkvUrvNFclfAer6UPfnM5oFE0jgxdPop0XzLQPujAnwbeOilOywY9b4JLYg/zRb4T1Olh4AdxP87460m4SLkGSR1DcRcWnV/tqYo/EJIVLE7aMjuZajaWLEagUUpK/sVJcOLGbWpKlC0aHJRsrNPJcUOveyV6Ub6zMRWMpCFYFDrlfR3EDvh74jP9Tj8s+M2RPmWjnEhOVpW2mAWnW21ZpxeNZk=
install:
- curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash
- helm version --client
- sudo pip install yamllint=="${YAMLLINT_VERSION}"
script:
- |
helm lint ${REPO_DIR}/charts/sitewhere-infrastructure
if [ $? != 0 ]; then
travis_terminate 1
fi
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)
# Useful URLs
REPO_URL=`git config remote.origin.url`
SSH_REPO=${REPO_URL/https:\/\/github.com\//git@github.com:}
SHA=`git rev-parse --verify HEAD`
# Push temporary directory to the stack
pushd $BUILD_DIR
wget ${GH_URL}/index.yaml
# Add Helm Repositories
helm repo add stable https://charts.helm.sh/stable
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add sitewhere https://sitewhere.io/helm-charts
helm repo add smizy https://smizy.github.io/charts
helm repo add k8s-at-home https://k8s-at-home.com/charts
helm repo add strimzi https://strimzi.io/charts
helm repo add codecentric https://codecentric.github.io/helm-charts
# Update Repositories
helm repo update
# Iterate over all charts are package them
#for dir in `ls ${REPO_DIR}/charts`; do
# helm dep update ${REPO_DIR}/charts/$dir
# helm package ${REPO_DIR}/charts/$dir
#done
helm dep update ${REPO_DIR}/charts/sitewhere-infrastructure
helm package ${REPO_DIR}/charts/sitewhere-infrastructure
# Indexing of charts
if [ -f index.yaml ]; then
helm repo index --url ${GH_URL} --merge index.yaml .
else
helm repo index --url ${GH_URL} .
fi
# Pop temporary directory from the stack
popd
# List all the contents that we will push
ls ${BUILD_DIR}
# Clone repository and empty target branch
git clone ${TARGET_REPO_URL} out
cd out
git checkout ${TARGET_BR} || git checkout --orphan ${TARGET_BR}
cd ..
# Don erase prev versions.
#rm -rf out/helm-charts/* || exit 0
# Copying contents of BUILD_DIR to out folder
cp $BUILD_DIR/* out/helm-charts/
cd out
# Deploy if there are some changes
git diff --quiet
if [ $? != 0 ]; then
# Add all new files to staging phase and commit the changes
git config user.name "Travis CI"
git config user.email "travis@travis-ci.org"
git add -A .
git status
git commit -m "Travis deploy ${SHA}"
# We can push.
git remote add origin-helm https://${GH_TOKEN}@github.com/sitewhere/sitewhere.github.io.git > /dev/null 2>&1
git push --quiet --set-upstream origin-helm master
fi
fi
notifications:
email: true
slack:
on_success: change
on_failure: always