-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·26 lines (23 loc) · 775 Bytes
/
build.sh
File metadata and controls
executable file
·26 lines (23 loc) · 775 Bytes
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
#!/usr/bin/env bash
readonly GIT_BRANCH=${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}
readonly DOCKER_IMAGE_TAG=$([[ $GIT_BRANCH == "master" ]] && echo -n "latest" || sed 's/[^a-zA-Z0-9]/-/g' <<< "$GIT_BRANCH")
readonly IMAGE_NAME="scottg489/machine-setup-build:$DOCKER_IMAGE_TAG"
readonly RUN_TASK=$1
readonly ID_RSA=$2
readonly AWS_CREDENTIALS=$3
readonly MAIN_KEY_PAIR=$4
read -r -d '' JSON_BODY <<- EOM
{
"RUN_TASK": "$RUN_TASK",
"GIT_BRANCH": "$GIT_BRANCH",
"ID_RSA": "$ID_RSA",
"AWS_CREDENTIALS": "$AWS_CREDENTIALS",
"MAIN_KEY_PAIR": "$MAIN_KEY_PAIR"
}
EOM
curl -v -sS -w '\n%{http_code}' \
--data-binary "$JSON_BODY" \
"https://api.conjob.io/job/run?image=$IMAGE_NAME&remove=true" \
| tee /tmp/foo \
| sed '$d' && \
[ "$(tail -1 /tmp/foo)" -eq 200 ]