1
+ #! /usr/bin/env bash
2
+
3
+ # This script aims at helping create a PR to update the manifests of the
4
+ # kubeflow/model-registry repo.
5
+ # This script:
6
+ # 1. Checks out a new branch
7
+ # 2. Copies files to the correct places
8
+ # 3. Commits the changes
9
+ #
10
+ # Afterwards the developers can submit the PR to the kubeflow/manifests
11
+ # repo, based on that local branch
12
+
13
+ # strict mode http://redsymbol.net/articles/unofficial-bash-strict-mode/
14
+ set -euo pipefail
15
+ IFS=$' \n\t '
16
+
17
+ DEV_MODE=${DEV_MODE:= false}
18
+ SRC_DIR=${SRC_DIR:=/ tmp/ kubeflow-model-registry}
19
+ BRANCH=${BRANCH:= sync-kubeflow-model-registry-manifests-${COMMIT?} }
20
+
21
+ SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
22
+ MANIFESTS_DIR=$( dirname $SCRIPT_DIR )
23
+
24
+ if [ " $DEV_MODE " != " false" ]; then
25
+ echo " WARNING: Dev mode enabled..."
26
+ fi
27
+
28
+ echo " Creating branch: ${BRANCH} "
29
+
30
+ # DEV: Comment out this if you are testing locally
31
+ if [ -n " $( git status --porcelain) " ]; then
32
+ # Uncommitted changes
33
+ echo " WARNING: You have uncommitted changes, exiting..."
34
+ exit 1
35
+ fi
36
+
37
+ if [ ` git branch --list $BRANCH ` ]
38
+ then
39
+ echo " WARNING: Branch $BRANCH already exists. Exiting..."
40
+ exit 1
41
+ fi
42
+
43
+ # DEV: If you are testing locally set DEV_MODE=true to skip this step
44
+ if [ " $DEV_MODE " = " false" ]; then
45
+ git checkout -b $BRANCH
46
+ fi
47
+
48
+ echo " Checking out in $SRC_DIR to $COMMIT ..."
49
+ cd $SRC_DIR
50
+ if [ -n " $( git status --porcelain) " ]; then
51
+ # Uncommitted changes
52
+ echo " WARNING: You have uncommitted changes, exiting..."
53
+ exit 1
54
+ fi
55
+ git checkout $COMMIT
56
+
57
+ echo " Copying model-registry manifests..."
58
+ DST_DIR=$MANIFESTS_DIR /apps/model-registry/upstream
59
+ rm -rf $DST_DIR
60
+ mkdir -p $DST_DIR
61
+ cp $SRC_DIR /manifests/kustomize/* $DST_DIR -r
62
+
63
+ echo " Successfully copied all manifests."
64
+
65
+ echo " Updating README..."
66
+ SRC_TXT=" \[.*\](https://github.com/kubeflow/model-registry/tree/.*/manifests/kustomize)"
67
+ DST_TXT=" \[$COMMIT \](https://github.com/kubeflow/model-registry/tree/$COMMIT /manifests/kustomize)"
68
+
69
+ sed -i " s|$SRC_TXT |$DST_TXT |g" ${MANIFESTS_DIR} /README.md
70
+
71
+ # DEV: If you are testing locally set DEV_MODE=true to skip this step
72
+ if [ " $DEV_MODE " = " false" ]; then
73
+ echo " Committing the changes..."
74
+ cd $MANIFESTS_DIR
75
+ git add apps
76
+ git add README.md
77
+ git commit -s -m " Update kubeflow/model-registry manifests from ${COMMIT} "
78
+ fi
0 commit comments