forked from ceph/ceph-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsingle-ceph-docker-workflow.sh
89 lines (75 loc) · 2.23 KB
/
single-ceph-docker-workflow.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
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
#!/bin/bash
BRANCH_NAME=""
BASEDIR=$(dirname "$0")
LOCAL_BRANCH=$(cd "$BASEDIR" && git rev-parse --abbrev-ref HEAD)
: "${PREFIX:=build}"
function test_args {
if [ $# -ne 3 ]; then
echo_info "Please run the script like this: ./script.sh CEPH_RELEASE DISTRO DISTRO_VERSION"
exit 1
fi
}
function echo_info {
echo ""
echo "**************************************************"
echo "$1"
echo "**************************************************"
echo ""
}
function move_back_to_initial_working_branch {
echo_info "MOVING BACK TO INITIAL BRANCH"
git checkout "$LOCAL_BRANCH"
}
function create_new_branch_name {
echo_info "CREATING NEW BRANCH NAME"
BRANCH_NAME=$PREFIX-$LOCAL_BRANCH-$1-$2-$3
}
function delete_old_branch_tag {
echo_info "DELETING OLD BRANCH"
git branch -D "$BRANCH_NAME" || true
git tag -d tag-"$BRANCH_NAME" || true
}
function create_new_branch {
echo_info "CREATING NEW BRANCH"
git checkout -b "$BRANCH_NAME"
}
function copy_files {
echo_info "COPYING FILES"
rm -rf base daemon demo
if ! echo "$2" | grep -sq redhat; then
cp -Lvr ceph-releases/"$1"/"$2"/"$3"/* .
fi
}
function commit_new_changes {
echo_info "CREATING COMMIT"
if [[ ! -d base ]] || [ ! -d demo ]; then
mkdir base demo
echo "workaround for kraken and above, do not care about me" > base/README.md
echo "workaround for kraken and above, do not care about me" > demo/README.md
fi
git add base daemon demo
git commit -s -m "Building $BRANCH_NAME"
}
function tag_new_changes {
echo_info "TAGGING NEW BRANCH"
git tag tag-"$BRANCH_NAME" "$(git log --format="%H" -n 1)"
}
function push_new_branch {
echo_info "PUSHING NEW BRANCH"
git push -f --tags origin "$BRANCH_NAME"
}
function trigger_build {
curl -H "Content-Type: application/json" --data '{"source_type": "Tag", "source_name": "$tag-"$BRANCH_NAME"}' -X POST https://registry.hub.docker.com/u/ceph/daemon/trigger/71c59f12-72d9-4d50-a69d-5bd186e6b3a6/
}
CEPH_RELEASE=$1
DISTRO=$2
DISTRO_VERSION=$3
test_args "$@"
create_new_branch_name "$CEPH_RELEASE" "$DISTRO" "$DISTRO_VERSION"
delete_old_branch_tag
create_new_branch
copy_files "$CEPH_RELEASE" "$DISTRO" "$DISTRO_VERSION"
commit_new_changes
tag_new_changes
push_new_branch
move_back_to_initial_working_branch