Skip to content

Commit 1ccd0d7

Browse files
authored
Add open-pr.sh script (#143)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent e9f1dd3 commit 1ccd0d7

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

hack/scripts/open-pr.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
3+
# Copyright AppsCode Inc. and Contributors
4+
#
5+
# Licensed under the AppsCode Community License 1.0.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://github.com/appscode/licenses/raw/1.0.0/AppsCode-Community-1.0.0.md
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -eou pipefail
18+
19+
SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)
20+
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
21+
pushd $SCRIPT_ROOT
22+
23+
# http://redsymbol.net/articles/bash-exit-traps/
24+
function cleanup() {
25+
popd
26+
}
27+
trap cleanup EXIT
28+
29+
git add --all
30+
if git diff -s --exit-code HEAD; then
31+
echo "CRDs are already up-to-date!"
32+
exit 0
33+
fi
34+
35+
pr_branch=${GITHUB_REPOSITORY}@${GITHUB_SHA:0:8}
36+
git checkout -b $pr_branch
37+
git commit -a -s -m "Update crds for $pr_branch"
38+
git push -u origin HEAD
39+
hub pull-request \
40+
--labels automerge \
41+
--message "Update crds for $pr_branch" \
42+
--message "$(git show -s --format=%b)"

0 commit comments

Comments
 (0)