-
Notifications
You must be signed in to change notification settings - Fork 2
/
createApp.sh
executable file
·68 lines (47 loc) · 1.69 KB
/
createApp.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
## Required Vars
# APP_ID
# REGION
# INSTANCE_GIT_REPO_TOKEN
# INSTANCE_GIT_REPO_OWNER
## Constructed Vars
export GIT_USERNAME=${INSTANCE_GIT_REPO_OWNER}
export GIT_TOKEN=${INSTANCE_GIT_REPO_TOKEN}
export GIT_BASE_URL=https://${INSTANCE_GIT_REPO_OWNER}@github.com/${INSTANCE_GIT_REPO_OWNER}
export BASE_DIR=${PWD}
export GIT_CMD=${BASE_DIR}/utils/git/gh.sh
export GIT_ASKPASS=${BASE_DIR}/utils/git/git-ask-pass.sh
## Verify Vars
echo GIT_ASKPASS=${GIT_ASKPASS}
echo REGION=${REGION}
echo APP_ID=${APP_ID}
echo INSTANCE_GIT_REPO_OWNER=${INSTANCE_GIT_REPO_OWNER}
echo GIT_USERNAME=${GIT_USERNAME}
echo INSTANCE_GIT_REPO_TOKEN=${INSTANCE_GIT_REPO_TOKEN}
echo GIT_TOKEN=$GIT_TOKEN
echo TEMPLATE_FOLDER=${TEMPLATE_FOLDER}
apt-get update
apt-get install curl gettext git -y
#git config --global user.email $(gcloud config get-value account)
git config --global user.email ${INSTANCE_GIT_REPO_OWNER}
git config --global user.name ${INSTANCE_GIT_REPO_OWNER}
#git clone https://github.com/gitrey/cp-templates.git util
#source $GIT_ASKPASS
printf 'Creating application: %s \n' $APP_ID
# # Create an instance of the template.
# Clone the template repo
rm -rf ./${TEMPLATE_FOLDER}/.git
cd ./${TEMPLATE_FOLDER}/
# Swap Variables
for template in $(find . -name '*.tmpl'); do envsubst < ${template} > ${template%.*}; done
# Create and push to new repo
git init
git checkout -b main
#git symbolic-ref HEAD refs/heads/main
echo create repo
${GIT_CMD} create ${APP_ID}
git remote add origin $GIT_BASE_URL/${APP_ID}
git add . && git commit -m "initial commit"
git push origin main
# Auth fails intermittetly on the very first client call for some reason
# Adding a retry to ensure the source is pushed.
git push origin main