forked from thomasdarimont/quarkus-google-cloud-run
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.cmd
69 lines (57 loc) · 2.64 KB
/
deploy.cmd
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
@ECHO off
@SETLOCAL
set CREATE_PROJECT=false
set PROJECT_PREFIX=hstucia
set REGION=europe-west1
set PROJECT_ID=%PROJECT_PREFIX%-gcp-quarkus-demo
set SERVICE_NAME=%PROJECT_PREFIX%-quarkus-demo-google-cloud-run
WHERE /Q gcloud
IF %ERRORLEVEL% NEQ 0 (
GOTO printInstructions
) else (
GOTO deploy
)
:createProject
ECHO Setting up %PROJECT_ID%
CALL gcloud projects create --no-user-output-enabled %PROJECT_ID%
CALL gcloud config set project --no-user-output-enabled %PROJECT_ID%
CALL gcloud config set run/region --no-user-output-enabled us-central1
CALL gcloud beta billing accounts list --format="table['box'](displayName,name)"
@REM It reads the account ID
SET /P ACCOUNT_ID="Enter the billing account ID you want to use: "
ECHO Enabling GCP services
CALL gcloud beta billing projects link --no-user-output-enabled %PROJECT_ID% --billing-account=%ACCOUNT_ID%
if %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
CALL gcloud services enable --no-user-output-enabled cloudbuild.googleapis.com
CALL gcloud services enable --no-user-output-enabled run.googleapis.com
FOR /F "tokens=*" %%a in ('gcloud beta projects describe %PROJECT_ID% --format="get(projectNumber)"') DO SET PROJECT_NUMBER=%%a
CALL gcloud projects add-iam-policy-binding --no-user-output-enabled %PROJECT_ID% --member serviceAccount:%PROJECT_NUMBER%@cloudbuild.gserviceaccount.com --role roles/run.admin
CALL gcloud projects add-iam-policy-binding --no-user-output-enabled %PROJECT_ID% --member serviceAccount:%PROJECT_NUMBER%@cloudbuild.gserviceaccount.com --role roles/iam.serviceAccountUser
ECHO Building %SERVICE_NAME%
CALL gcloud builds submit --no-user-output-enabled --config cloudbuild.yaml .
if %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO You can access your application at:
CALL gcloud beta run services describe %SERVICE_NAME% --format="get(domain)"
EXIT /B 0
:deployProject
ECHO Building %SERVICE_NAME%
CALL gcloud config set project --no-user-output-enabled %PROJECT_ID%
CALL gcloud config set run/platform managed
CALL gcloud config set run/region %REGION%
CALL gcloud builds submit --no-user-output-enabled --config cloudbuild.yaml .
if %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
ECHO You can access your application at:
CALL gcloud run services describe %SERVICE_NAME% --format="get(domain)"
EXIT /B 0
:deploy
IF "%CREATE_PROJECT%" == "true" (
GOTO createProject
) ELSE (
GOTO deployProject
)
:printInstructions
ECHO ========================================================================
ECHO In order to deploy this project, you need gcloud set in your PATH.
ECHO You can download it from https://cloud.google.com/sdk
ECHO ========================================================================
EXIT /B 0