forked from drupalwxt/helm-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
97 lines (96 loc) · 4.02 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
#
# This script is based on the https://github.com/Azure/helm-elasticstack/blob/master/.travis.yml
#
# MIT License
#
# Copyright (c) Microsoft Corporation. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE
matrix:
include:
- language: generic
env:
- KUBECTL_VERSION=v1.14.1
- HELM_VERSION=v2.13.1
- TARGET_BR=gh-pages
- REPO_DIR=/home/travis/build/drupalwxt/helm-drupal
- GH_URL=https://drupalwxt.github.io/helm-drupal
- REPO_URL=https://${GH_TOKEN}@github.com/drupalwxt/helm-drupal.git
install:
- wget https://storage.googleapis.com/kubernetes-release/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl -O /tmp/kubectl
- chmod +x /tmp/kubectl
- wget http://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz -O /tmp/helm.tar.gz
- tar xzf /tmp/helm.tar.gz -C /tmp --strip-components=1
- chmod +x /tmp/helm
- export PATH=$PATH:/tmp
before_script:
- helm init --client-only
- helm repo add stable https://kubernetes-charts.storage.googleapis.com
- |
for chart in $(find . -name 'requirements.yaml'); do
helm dep build $(dirname ${chart})
done
script:
- |
for chart in $(find . -name 'requirements.yaml'); do
helm lint $(dirname ${chart})
done
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
helm dep update ${REPO_DIR}/drupal
helm package ${REPO_DIR}/drupal
# 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 ${REPO_URL} out
cd out
git checkout ${TARGET_BR} || git checkout --orphan ${TARGET_BR}
cd ..
rm -rf out/* || exit 0
# Copying contents of BUILD_DIR to out folder
cp $BUILD_DIR/* out/
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
SHA=`git rev-parse --verify HEAD`
git config user.name "Travis CI"
git config user.email "[email protected]"
git add -A .
git status
git commit -m "Travis deploy ${SHA}"
# We can push.
git push ${REPO_URL}
fi
fi