forked from kubevirt/common-templates
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease-templates-ssp-operator.sh
executable file
·60 lines (50 loc) · 1.74 KB
/
release-templates-ssp-operator.sh
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
#!/bin/bash
#
# This file is part of the KubeVirt project
#
# 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.
#
# Copyright 2019 Red Hat, Inc.
#
set -e
if [ -z "${TRAVIS_TAG}" ]; then
echo "TRAVIS_TAG can't be empty" && exit 1
fi
if [ -z "${GITHUB_TOKEN}" ]; then
echo "GITHUB_TOKEN can't be empty" && exit 1
fi
git clone ${SSP_REPO_URL}
cd ${SSP_REPO}
branch="update-common-templates-${TRAVIS_TAG}"
git checkout -b $branch
git reset origin/master --hard
# Copy latest templates to ssp repo
cp ../dist/common-templates-${TRAVIS_TAG}.yaml roles/KubevirtCommonTemplatesBundle/files
# Replace templates_version to latest release
sed -i '/^templates_version.*/c\templates_version: '${TRAVIS_TAG} _defaults.yml
# Add only updated files and nothing else
git add _defaults.yml roles/KubevirtCommonTemplatesBundle/files/common-templates-${TRAVIS_TAG}.yaml
message="updated common templates to version ${TRAVIS_TAG}"
git commit -m "$message"
git push origin $branch --force
sleep 5
payload=$(cat <<- EOF
{
"title": "${message}",
"body": "${message}",
"head": "$branch",
"base": "master"
}
EOF
)
curl -d "$payload" -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/json" -X POST https://api.github.com/repos/${SSP_OWNER}/${SSP_REPO}/pulls 1> /dev/null