-
Notifications
You must be signed in to change notification settings - Fork 3
/
create_gitlab_variables.sh
executable file
·35 lines (26 loc) · 1.2 KB
/
create_gitlab_variables.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
#!/bin/bash
. .gitlab-env
function create_key {
GITLAB_API="https://gitlab.com/api/v3/projects/$GITLAB_PROJECT_ID/variables"
curl --request POST --header "PRIVATE-TOKEN: $GITLAB_PRIVATE_TOKEN" "$GITLAB_API" --form "key=$1" --form "value=$2"
}
GCLOUD_PROJECT_ID=${1:-"$GCLOUD_PROJECT_ID"}
GITLAB_PROJECT_ID=${2:-"$GITLAB_PROJECT_ID"}
if [[ "$GCLOUD_PROJECT_ID" = "" ]]; then
echo "usage specify GCLOUD_PROJECT_ID";
exit 1;
fi
GCLOUD_GITLAB_CI_SERVICE_ACCOUNT_KEY=`cat gitlab-ci-token.json | base64`
create_key "GCLOUD_GITLAB_CI_SERVICE_ACCOUNT_KEY" "$GCLOUD_GITLAB_CI_SERVICE_ACCOUNT_KEY"
CI_REGISTRY_IMAGE="eu.gcr.io/$GCLOUD_PROJECT_ID/kbnw-express-app"
create_key "CI_REGISTRY_IMAGE" "$CI_REGISTRY_IMAGE"
GCLOUD_GITLAB_CI_SERVICE_ACCOUNT="gitlab-ci-token@$GCLOUD_PROJECT_ID.iam.gserviceaccount.com"
create_key "GCLOUD_GITLAB_CI_SERVICE_ACCOUNT" "$GCLOUD_GITLAB_CI_SERVICE_ACCOUNT"
GCLOUD_PROJECT=$GCLOUD_PROJECT_ID
create_key "GCLOUD_PROJECT" "$GCLOUD_PROJECT"
create_key "CLUSTER_NAME" "$CLUSTER_NAME"
create_key "GCLOUD_ZONE" "$GCLOUD_ZONE"
create_key "DOMAIN" "$DOMAIN"
create_key "PROD_SUBDOMAIN" "$PROD_SUBDOMAIN"
create_key "STAGING_SUBDOMAIN" "$STAGING_SUBDOMAIN"
create_key "DOCKER_HOST" "$DOCKER_HOST"