forked from aws-amplify/amplify-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloud-cli-utils.sh
More file actions
38 lines (36 loc) · 1.38 KB
/
Copy pathcloud-cli-utils.sh
File metadata and controls
38 lines (36 loc) · 1.38 KB
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
#!/bin/bash
# set exit on error to true
set -e
# load .env
set -o allexport
source ./scripts/.env set
function authenticate {
account_number=$1
role_name=$2
profile_name=$3
echo Authenticating terminal...
mwinit
echo Loading account credentials for Account $account_number with Role: $role_name...
ada cred update --profile="${profile_name}" --account="${account_number}" --role=${role_name} --provider=isengard --once
aws configure set region us-east-1 --profile $profile_name
}
function triggerProjectBatch {
account_number=$1
role_name=$2
profile_name=$3
project_name=$4
target_branch=$5
npm_tag=$6
authenticate $account_number $role_name $profile_name
echo AWS Account: $account_number
echo Project: $project_name
echo Target Branch: $target_branch
if [[ "$npm_tag" != "" ]]; then
echo NPM tag: $npm_tag
npm_variable_override="name=NPM_TAG,value=$npm_tag,type=PLAINTEXT"
fi
RESULT=$(aws codebuild start-build-batch --profile="${profile_name}" --project-name $project_name --source-version=$target_branch \
--environment-variables-override name=BRANCH_NAME,value=$target_branch,type=PLAINTEXT $npm_variable_override \
--query 'buildBatch.id' --output text)
echo "https://us-east-1.console.aws.amazon.com/codesuite/codebuild/$account_number/projects/$project_name/batch/$RESULT?region=us-east-1"
}