@catladder/pipeline 1.170.1 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/dist/bash/BashExpression.d.ts +1 -6
  2. package/dist/bash/BashExpression.js +2 -15
  3. package/dist/bash/bashEscape.d.ts +34 -0
  4. package/dist/bash/bashEscape.js +114 -0
  5. package/dist/bash/bashYaml.js +25 -2
  6. package/dist/bash/getInjectVarsScript.js +4 -2
  7. package/dist/bash/index.d.ts +2 -0
  8. package/dist/bash/index.js +26 -0
  9. package/dist/build/base/createAppBuildJob.js +3 -3
  10. package/dist/build/base/writeDotEnv.js +6 -4
  11. package/dist/build/custom/testJob.js +12 -12
  12. package/dist/build/docker.d.ts +3 -3
  13. package/dist/build/node/buildJob.js +1 -1
  14. package/dist/build/node/cache.d.ts +2 -4
  15. package/dist/build/node/cache.js +3 -24
  16. package/dist/build/node/testJob.js +11 -11
  17. package/dist/build/rails/build.js +1 -1
  18. package/dist/build/rails/test.js +8 -8
  19. package/dist/build/types.d.ts +0 -10
  20. package/dist/constants.js +1 -1
  21. package/dist/context/createComponentContext.js +0 -1
  22. package/dist/context/getEnvConfig.js +2 -1
  23. package/dist/context/getEnvironment.js +1 -2
  24. package/dist/context/getEnvironmentVariables.d.ts +5 -6
  25. package/dist/context/getEnvironmentVariables.js +50 -38
  26. package/dist/deploy/base/deploy.js +3 -3
  27. package/dist/deploy/cloudRun/createJobs/getCloudRunDeployScripts.js +2 -2
  28. package/dist/deploy/cloudRun/index.js +2 -2
  29. package/dist/deploy/cloudRun/utils/getServiceName.d.ts +1 -1
  30. package/dist/deploy/kubernetes/cloudSql/index.d.ts +2 -2
  31. package/dist/deploy/kubernetes/cloudSql/index.js +3 -14
  32. package/dist/deploy/kubernetes/deployJob.js +1 -3
  33. package/dist/deploy/kubernetes/index.js +2 -2
  34. package/dist/deploy/kubernetes/kubeEnv.d.ts +3 -3
  35. package/dist/deploy/kubernetes/kubeValues.d.ts +3 -4
  36. package/dist/deploy/kubernetes/kubeValues.js +2 -3
  37. package/dist/deploy/types/base.d.ts +0 -6
  38. package/dist/deploy/types/kubernetes.d.ts +1 -34
  39. package/dist/globalScriptFunctions/index.d.ts +14 -0
  40. package/dist/globalScriptFunctions/index.js +37 -0
  41. package/dist/index.d.ts +3 -1
  42. package/dist/index.js +3 -1
  43. package/dist/pipeline/gitlab/createGitlabJobs.js +3 -5
  44. package/dist/pipeline/gitlab/createGitlabPipeline.d.ts +1 -0
  45. package/dist/pipeline/gitlab/createGitlabPipeline.js +38 -2
  46. package/dist/pipeline/packageManager.js +1 -1
  47. package/dist/runner/index.d.ts +1 -1
  48. package/dist/tsconfig.tsbuildinfo +1 -1
  49. package/dist/types/config.d.ts +6 -9
  50. package/dist/types/context.d.ts +2 -9
  51. package/dist/types/gitlab-types.d.ts +1 -0
  52. package/dist/types/jobs.d.ts +0 -8
  53. package/dist/utils/gitlab.js +4 -1
  54. package/dist/utils/writeFiles.js +1 -7
  55. package/dist/variables/VariableValue.d.ts +3 -0
  56. package/dist/variables/VariableValue.js +5 -0
  57. package/dist/variables/VariableValueContainingReferences.d.ts +24 -0
  58. package/dist/variables/VariableValueContainingReferences.js +97 -0
  59. package/dist/variables/__tests__/resolveAllReferences.test.js +219 -0
  60. package/dist/variables/__tests__/resolveAllReferencesOnce.test.d.ts +1 -0
  61. package/dist/variables/__tests__/resolveAllReferencesOnce.test.js +171 -0
  62. package/dist/variables/__tests__/resolveReferencesOnce.test.d.ts +1 -0
  63. package/dist/variables/__tests__/resolveReferencesOnce.test.js +202 -0
  64. package/dist/variables/__tests__/variableValue.test.d.ts +1 -0
  65. package/dist/variables/__tests__/variableValue.test.js +36 -0
  66. package/dist/variables/resolveAllReferences.d.ts +3 -0
  67. package/dist/{bash/replaceAsync.js → variables/resolveAllReferences.js} +60 -40
  68. package/dist/variables/resolveAllReferencesOnce.d.ts +5 -0
  69. package/dist/variables/resolveAllReferencesOnce.js +191 -0
  70. package/dist/variables/resolveReferencesOnce.d.ts +8 -0
  71. package/dist/variables/resolveReferencesOnce.js +22 -0
  72. package/examples/__snapshots__/cloud-run-http2.test.ts.snap +312 -238
  73. package/examples/__snapshots__/cloud-run-memory-limit.test.ts.snap +312 -238
  74. package/examples/__snapshots__/cloud-run-meteor-with-worker.test.ts.snap +312 -222
  75. package/examples/__snapshots__/cloud-run-nextjs.test.ts.snap +1436 -0
  76. package/examples/__snapshots__/cloud-run-no-cpu-throttling.test.ts.snap +312 -238
  77. package/examples/__snapshots__/cloud-run-no-service.test.ts.snap +316 -238
  78. package/examples/__snapshots__/cloud-run-non-public.test.ts.snap +312 -238
  79. package/examples/__snapshots__/cloud-run-post-stop-job.test.ts.snap +313 -238
  80. package/examples/__snapshots__/cloud-run-service-custom-vpc-connector.test.ts.snap +312 -238
  81. package/examples/__snapshots__/cloud-run-service-custom-vpc.test.ts.snap +312 -238
  82. package/examples/__snapshots__/cloud-run-service-gen2.test.ts.snap +312 -238
  83. package/examples/__snapshots__/cloud-run-service-increase-timout.test.ts.snap +312 -238
  84. package/examples/__snapshots__/cloud-run-service-with-volumes.test.ts.snap +316 -238
  85. package/examples/__snapshots__/cloud-run-storybook.test.ts.snap +294 -220
  86. package/examples/__snapshots__/cloud-run-with-ngnix.test.ts.snap +312 -238
  87. package/examples/__snapshots__/cloud-run-with-sql-reuse-db.test.ts.snap +652 -486
  88. package/examples/__snapshots__/cloud-run-with-sql.test.ts.snap +282 -288
  89. package/examples/__snapshots__/cloud-run-with-worker.test.ts.snap +312 -238
  90. package/examples/__snapshots__/custom-build-job-with-tests.test.ts.snap +284 -194
  91. package/examples/__snapshots__/custom-build-job.test.ts.snap +278 -188
  92. package/examples/__snapshots__/custom-deploy.test.ts.snap +220 -154
  93. package/examples/__snapshots__/custom-envs.test.ts.snap +216 -126
  94. package/examples/__snapshots__/custom-sbom-java.test.ts.snap +278 -188
  95. package/examples/__snapshots__/git-submodule.test.ts.snap +312 -238
  96. package/examples/__snapshots__/kubernetes-application-customization.test.ts.snap +231 -253
  97. package/examples/__snapshots__/kubernetes-with-cloud-sql.test.ts.snap +240 -262
  98. package/examples/__snapshots__/kubernetes-with-jobs.test.ts.snap +504 -506
  99. package/examples/__snapshots__/kubernetes-with-mongodb.test.ts.snap +239 -261
  100. package/examples/__snapshots__/local-dot-env.test.ts.snap +236 -238
  101. package/examples/__snapshots__/meteor-kubernetes.test.ts.snap +236 -242
  102. package/examples/__snapshots__/multiline-var.test.ts.snap +1355 -973
  103. package/examples/__snapshots__/native-app.test.ts.snap +438 -392
  104. package/examples/__snapshots__/node-build-with-custom-image.test.ts.snap +312 -238
  105. package/examples/__snapshots__/node-build-with-docker-additions.test.ts.snap +312 -238
  106. package/examples/__snapshots__/rails-k8s-with-worker-dockerfile.test.ts.snap +186 -188
  107. package/examples/__snapshots__/rails-k8s-with-worker.test.ts.snap +162 -164
  108. package/examples/__snapshots__/referencing-other-vars.test.ts.snap +971 -765
  109. package/examples/__snapshots__/wait-for-other-deploy.test.ts.snap +330 -228
  110. package/examples/__snapshots__/{workspace-api-www-custom-cache.test.ts.snap → workspace-api-www-turbo-cache.test.ts.snap} +457 -499
  111. package/examples/__snapshots__/workspace-api-www.test.ts.snap +452 -482
  112. package/examples/{workspace-api-www-custom-cache.test.ts → cloud-run-nextjs.test.ts} +2 -2
  113. package/examples/cloud-run-nextjs.ts +28 -0
  114. package/examples/cloud-run-with-sql.ts +0 -1
  115. package/examples/kubernetes-application-customization.ts +1 -0
  116. package/examples/kubernetes-with-cloud-sql.ts +1 -0
  117. package/examples/kubernetes-with-jobs.ts +1 -0
  118. package/examples/kubernetes-with-mongodb.ts +1 -0
  119. package/examples/meteor-kubernetes.ts +1 -1
  120. package/examples/native-app.ts +10 -7
  121. package/examples/rails-k8s-with-worker.ts +7 -1
  122. package/examples/{kubernetes-with-cloud-sql-legacy.test.ts → workspace-api-www-turbo-cache.test.ts} +2 -2
  123. package/examples/{workspace-api-www-custom-cache.ts → workspace-api-www-turbo-cache.ts} +4 -3
  124. package/examples/workspace-api-www.ts +3 -2
  125. package/package.json +2 -6
  126. package/scripts/generate-examples-test.ts +0 -7
  127. package/src/bash/BashExpression.ts +0 -13
  128. package/src/bash/bashEscape.ts +158 -0
  129. package/src/bash/bashYaml.ts +36 -2
  130. package/src/bash/getInjectVarsScript.ts +11 -2
  131. package/src/bash/index.ts +2 -0
  132. package/src/build/base/createAppBuildJob.ts +0 -1
  133. package/src/build/base/writeDotEnv.ts +6 -6
  134. package/src/build/custom/testJob.ts +0 -1
  135. package/src/build/node/buildJob.ts +2 -2
  136. package/src/build/node/cache.ts +0 -29
  137. package/src/build/node/testJob.ts +0 -1
  138. package/src/build/rails/build.ts +0 -1
  139. package/src/build/rails/test.ts +0 -1
  140. package/src/build/types.ts +0 -13
  141. package/src/context/createComponentContext.ts +0 -1
  142. package/src/context/getEnvConfig.ts +2 -2
  143. package/src/context/getEnvironment.ts +1 -1
  144. package/src/context/getEnvironmentContext.ts +1 -1
  145. package/src/context/getEnvironmentVariables.ts +44 -51
  146. package/src/deploy/base/deploy.ts +1 -1
  147. package/src/deploy/cloudRun/createJobs/getCloudRunDeployScripts.ts +4 -12
  148. package/src/deploy/cloudRun/index.ts +2 -2
  149. package/src/deploy/kubernetes/cloudSql/index.ts +3 -16
  150. package/src/deploy/kubernetes/deployJob.ts +0 -2
  151. package/src/deploy/kubernetes/index.ts +2 -2
  152. package/src/deploy/kubernetes/kubeEnv.ts +3 -3
  153. package/src/deploy/kubernetes/kubeValues.ts +5 -8
  154. package/src/deploy/types/base.ts +0 -6
  155. package/src/deploy/types/kubernetes.ts +1 -36
  156. package/src/globalScriptFunctions/index.ts +30 -0
  157. package/src/index.ts +2 -0
  158. package/src/pipeline/gitlab/createGitlabJobs.ts +1 -4
  159. package/src/pipeline/gitlab/createGitlabPipeline.ts +8 -1
  160. package/src/pipeline/packageManager.ts +7 -5
  161. package/src/runner/index.ts +0 -1
  162. package/src/types/config.ts +6 -9
  163. package/src/types/context.ts +3 -9
  164. package/src/types/gitlab-types.ts +1 -0
  165. package/src/types/jobs.ts +0 -8
  166. package/src/utils/gitlab.ts +19 -2
  167. package/src/utils/writeFiles.ts +1 -2
  168. package/src/variables/VariableValue.ts +6 -0
  169. package/src/variables/VariableValueContainingReferences.ts +89 -0
  170. package/src/variables/__tests__/resolveAllReferences.test.ts +110 -0
  171. package/src/variables/__tests__/resolveAllReferencesOnce.test.ts +64 -0
  172. package/src/variables/__tests__/resolveReferencesOnce.test.ts +117 -0
  173. package/src/variables/__tests__/variableValue.test.ts +73 -0
  174. package/src/variables/resolveAllReferences.ts +46 -0
  175. package/src/variables/resolveAllReferencesOnce.ts +44 -0
  176. package/src/variables/resolveReferencesOnce.ts +29 -0
  177. package/bin/catladder-gitlab-dev.js +0 -3
  178. package/bin/catladder-gitlab.js +0 -3
  179. package/dist/bash/replaceAsync.d.ts +0 -2
  180. package/dist/bundles/catladder-gitlab/index.js +0 -15
  181. package/dist/context/__tests__/resolveReferences.test.js +0 -368
  182. package/dist/context/resolveReferences.d.ts +0 -6
  183. package/dist/context/resolveReferences.js +0 -286
  184. package/dist/deploy/kubernetes/processSecretsAsFiles.d.ts +0 -85
  185. package/dist/deploy/kubernetes/processSecretsAsFiles.js +0 -33
  186. package/examples/__snapshots__/kubernetes-with-cloud-sql-legacy.test.ts.snap +0 -1795
  187. package/examples/kubernetes-with-cloud-sql-legacy.ts +0 -35
  188. package/scripts/bundle +0 -2
  189. package/src/bash/replaceAsync.ts +0 -49
  190. package/src/context/__tests__/resolveReferences.test.ts +0 -148
  191. package/src/context/resolveReferences.ts +0 -93
  192. package/src/deploy/kubernetes/processSecretsAsFiles.ts +0 -35
  193. /package/dist/{context/__tests__/resolveReferences.test.d.ts → variables/__tests__/resolveAllReferences.test.d.ts} +0 -0
@@ -45,6 +45,36 @@ variables:
45
45
  CACHE_COMPRESSION_LEVEL: fast
46
46
  TRANSFER_METER_FREQUENCY: 5s
47
47
  GIT_DEPTH: '1'
48
+ before_script:
49
+ - |-
50
+ function escapeForDotEnv () {
51
+ input="\${1:-$(cat)}"
52
+ input="\${input//$'\\n'/\\\\n}"
53
+ if [[ "$input" == *\\\\n* ]]; then
54
+ if [[ "$input" == *\\"* && "$input" == *\\'* && "$input" == *\\\`* ]]; then
55
+ printf "\\"%s\\"\\n" "$input"
56
+ elif [[ "$input" == *\\"* && "$input" == *\\'* ]]; then
57
+ printf "\`%s\`\\n" "$input"
58
+ elif [[ "$input" == *\\"* ]]; then
59
+ printf "'%s'\\n" "$input"
60
+ else
61
+ printf "\\"%s\\"\\n" "$input"
62
+ fi
63
+ else
64
+ printf "%s\\n" "$input"
65
+ fi
66
+ }
67
+ - |-
68
+ function collapseable_section_start () {
69
+ local section_title="\${1}"
70
+ local section_description="\${2:-$section_title}"
71
+ echo -e "section_start:\`date +%s\`:\${section_title}[collapsed=true]\\r\\e[0K\${section_description}"
72
+ }
73
+ - |-
74
+ function collapseable_section_end () {
75
+ local section_title="\${1}"
76
+ echo -e "section_end:\`date +%s\`:\${section_title}\\r\\e[0K"
77
+ }
48
78
  app 🛡 audit:
49
79
  stage: test
50
80
  image: path/to/docker/jobs-default:the-version
@@ -53,11 +83,11 @@ app 🛡 audit:
53
83
  KUBERNETES_MEMORY_REQUEST: 1Gi
54
84
  KUBERNETES_MEMORY_LIMIT: 4Gi
55
85
  script:
56
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
86
+ - collapseable_section_start "injectvars" "Injecting variables"
57
87
  - export APP_PATH="app"
58
88
  - export LC_A="L=en_US.UTF-8"
59
89
  - export LANG="en_US.UTF-8"
60
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
90
+ - collapseable_section_end "injectvars"
61
91
  - cd app
62
92
  - yarn npm audit --environment production
63
93
  rules:
@@ -81,23 +111,23 @@ app 👮 lint:
81
111
  KUBERNETES_MEMORY_REQUEST: 1Gi
82
112
  KUBERNETES_MEMORY_LIMIT: 4Gi
83
113
  script:
84
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
114
+ - collapseable_section_start "injectvars" "Injecting variables"
85
115
  - export APP_PATH="app"
86
116
  - export LC_A="L=en_US.UTF-8"
87
117
  - export LANG="en_US.UTF-8"
88
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
89
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
118
+ - collapseable_section_end "injectvars"
119
+ - collapseable_section_start "nodeinstall" "Ensure node version"
90
120
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
91
121
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
92
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
122
+ - collapseable_section_end "nodeinstall"
93
123
  - cd app
94
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
124
+ - collapseable_section_start "nodeinstall" "Ensure node version"
95
125
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
96
126
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
97
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
98
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
127
+ - collapseable_section_end "nodeinstall"
128
+ - collapseable_section_start "yarninstall" "Yarn install"
99
129
  - yarn install --immutable
100
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
130
+ - collapseable_section_end "yarninstall"
101
131
  - yarn lint
102
132
  cache:
103
133
  - key: app-yarn
@@ -124,23 +154,23 @@ app 🧪 test:
124
154
  KUBERNETES_MEMORY_REQUEST: 1Gi
125
155
  KUBERNETES_MEMORY_LIMIT: 4Gi
126
156
  script:
127
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
157
+ - collapseable_section_start "injectvars" "Injecting variables"
128
158
  - export APP_PATH="app"
129
159
  - export LC_A="L=en_US.UTF-8"
130
160
  - export LANG="en_US.UTF-8"
131
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
132
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
161
+ - collapseable_section_end "injectvars"
162
+ - collapseable_section_start "nodeinstall" "Ensure node version"
133
163
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
134
164
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
135
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
165
+ - collapseable_section_end "nodeinstall"
136
166
  - cd app
137
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
167
+ - collapseable_section_start "nodeinstall" "Ensure node version"
138
168
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
139
169
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
140
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
141
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
170
+ - collapseable_section_end "nodeinstall"
171
+ - collapseable_section_start "yarninstall" "Yarn install"
142
172
  - yarn install --immutable
143
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
173
+ - collapseable_section_end "yarninstall"
144
174
  - yarn test
145
175
  cache:
146
176
  - key: app-yarn
@@ -169,57 +199,55 @@ app 🧪 test:
169
199
  KUBERNETES_MEMORY_REQUEST: 1Gi
170
200
  KUBERNETES_MEMORY_LIMIT: 4Gi
171
201
  script:
172
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
202
+ - collapseable_section_start "injectvars" "Injecting variables"
173
203
  - export ENV_SHORT="dev"
174
204
  - export APP_DIR="app"
175
205
  - export ENV_TYPE="dev"
176
206
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
177
207
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
178
208
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
179
- - export HOST="unknown-host.example.com"
209
+ - export HOSTNAME="unknown-host.example.com"
180
210
  - export ROOT_URL="https://unknown-host.example.com"
181
- - export HOST_INTERNAL="unknown-host.example.com"
182
- - export HOST_CANONICAL="unknown-host.example.com"
211
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
183
212
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
184
213
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_dev_app_APP_STORE_CONNECT_API_KEY_CONTENT"
185
214
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_dev_app_APP_STORE_CONNECT_ISSUER_ID"
186
215
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_dev_app_APP_STORE_CONNECT_API_KEY_ID"
187
216
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
188
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
217
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
189
218
  - export LC_A="L=en_US.UTF-8"
190
219
  - export LANG="en_US.UTF-8"
191
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
192
- - echo -e "\\e[0Ksection_start:$(date +%s):write-dotenv-app[collapsed=true]\\r\\e[0Kwrite dot env"
220
+ - collapseable_section_end "injectvars"
221
+ - collapseable_section_start "write-dotenv-app" "write dot env for app"
193
222
  - |-
194
223
  cat <<EOF > app/.env
195
224
  ENV_SHORT=dev
196
225
  APP_DIR=app
197
226
  ENV_TYPE=dev
198
- HOST=unknown-host.example.com
227
+ HOSTNAME=unknown-host.example.com
199
228
  ROOT_URL=https://unknown-host.example.com
200
- HOST_INTERNAL=unknown-host.example.com
201
- HOST_CANONICAL=unknown-host.example.com
229
+ HOSTNAME_INTERNAL=unknown-host.example.com
202
230
  ROOT_URL_INTERNAL=https://unknown-host.example.com
203
- APP_STORE_CONNECT_API_KEY_CONTENT=$CL_dev_app_APP_STORE_CONNECT_API_KEY_CONTENT
204
- APP_STORE_CONNECT_ISSUER_ID=$CL_dev_app_APP_STORE_CONNECT_ISSUER_ID
205
- APP_STORE_CONNECT_API_KEY_ID=$CL_dev_app_APP_STORE_CONNECT_API_KEY_ID
206
- GRAPHQL_URL=https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql
207
- _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
231
+ APP_STORE_CONNECT_API_KEY_CONTENT=$(printf %s "$CL_dev_app_APP_STORE_CONNECT_API_KEY_CONTENT" | escapeForDotEnv)
232
+ APP_STORE_CONNECT_ISSUER_ID=$(printf %s "$CL_dev_app_APP_STORE_CONNECT_ISSUER_ID" | escapeForDotEnv)
233
+ APP_STORE_CONNECT_API_KEY_ID=$(printf %s "$CL_dev_app_APP_STORE_CONNECT_API_KEY_ID" | escapeForDotEnv)
234
+ GRAPHQL_URL=$(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql" | escapeForDotEnv)
235
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
208
236
  EOF
209
- - echo -e "\\e[0Ksection_end:$(date +%s):write-dotenv-app\\r\\e[0K"
237
+ - collapseable_section_end "write-dotenv-app"
210
238
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > app/__build_info.json
211
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
239
+ - collapseable_section_start "nodeinstall" "Ensure node version"
212
240
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
213
241
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
214
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
242
+ - collapseable_section_end "nodeinstall"
215
243
  - cd app
216
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
244
+ - collapseable_section_start "nodeinstall" "Ensure node version"
217
245
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
218
246
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
219
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
220
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
247
+ - collapseable_section_end "nodeinstall"
248
+ - collapseable_section_start "yarninstall" "Yarn install"
221
249
  - yarn install --immutable
222
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
250
+ - collapseable_section_end "yarninstall"
223
251
  - bundle config set --local path 'vendor/ruby'
224
252
  - gem install bundler
225
253
  - bundle install
@@ -234,10 +262,6 @@ app 🧪 test:
234
262
  policy: pull-push
235
263
  paths:
236
264
  - app/node_modules
237
- - key: app-next-cache
238
- policy: pull-push
239
- paths:
240
- - app/.next/cache
241
265
  - key:
242
266
  files:
243
267
  - app/Gemfile.lock
@@ -266,8 +290,8 @@ app 🧪 test:
266
290
  image: aquasec/trivy:0.38.3
267
291
  variables: {}
268
292
  script:
269
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
270
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
293
+ - collapseable_section_start "injectvars" "Injecting variables"
294
+ - collapseable_section_end "injectvars"
271
295
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" app
272
296
  artifacts:
273
297
  paths:
@@ -290,26 +314,25 @@ app 🧪 test:
290
314
  KUBERNETES_MEMORY_REQUEST: 200Mi
291
315
  KUBERNETES_MEMORY_LIMIT: 400Mi
292
316
  script:
293
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
317
+ - collapseable_section_start "injectvars" "Injecting variables"
294
318
  - export ENV_SHORT="dev"
295
319
  - export APP_DIR="app"
296
320
  - export ENV_TYPE="dev"
297
321
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
298
322
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
299
323
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
300
- - export HOST="unknown-host.example.com"
324
+ - export HOSTNAME="unknown-host.example.com"
301
325
  - export ROOT_URL="https://unknown-host.example.com"
302
- - export HOST_INTERNAL="unknown-host.example.com"
303
- - export HOST_CANONICAL="unknown-host.example.com"
326
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
304
327
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
305
328
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_dev_app_APP_STORE_CONNECT_API_KEY_CONTENT"
306
329
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_dev_app_APP_STORE_CONNECT_ISSUER_ID"
307
330
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_dev_app_APP_STORE_CONNECT_API_KEY_ID"
308
331
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
309
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
332
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
310
333
  - export LC_A="L=en_US.UTF-8"
311
334
  - export LANG="en_US.UTF-8"
312
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
335
+ - collapseable_section_end "injectvars"
313
336
  - cd app
314
337
  - bundle config set --local path 'vendor/ruby'
315
338
  - gem install bundler
@@ -353,57 +376,55 @@ app 🧪 test:
353
376
  KUBERNETES_MEMORY_REQUEST: 1Gi
354
377
  KUBERNETES_MEMORY_LIMIT: 4Gi
355
378
  script:
356
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
379
+ - collapseable_section_start "injectvars" "Injecting variables"
357
380
  - export ENV_SHORT="review"
358
381
  - export APP_DIR="app"
359
382
  - export ENV_TYPE="review"
360
383
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
361
384
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
362
385
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
363
- - export HOST="unknown-host.example.com"
386
+ - export HOSTNAME="unknown-host.example.com"
364
387
  - export ROOT_URL="https://unknown-host.example.com"
365
- - export HOST_INTERNAL="unknown-host.example.com"
366
- - export HOST_CANONICAL="unknown-host.example.com"
388
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
367
389
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
368
390
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_review_app_APP_STORE_CONNECT_API_KEY_CONTENT"
369
391
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_review_app_APP_STORE_CONNECT_ISSUER_ID"
370
392
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_review_app_APP_STORE_CONNECT_API_KEY_ID"
371
393
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
372
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
394
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
373
395
  - export LC_A="L=en_US.UTF-8"
374
396
  - export LANG="en_US.UTF-8"
375
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
376
- - echo -e "\\e[0Ksection_start:$(date +%s):write-dotenv-app[collapsed=true]\\r\\e[0Kwrite dot env"
397
+ - collapseable_section_end "injectvars"
398
+ - collapseable_section_start "write-dotenv-app" "write dot env for app"
377
399
  - |-
378
400
  cat <<EOF > app/.env
379
401
  ENV_SHORT=review
380
402
  APP_DIR=app
381
403
  ENV_TYPE=review
382
- HOST=unknown-host.example.com
404
+ HOSTNAME=unknown-host.example.com
383
405
  ROOT_URL=https://unknown-host.example.com
384
- HOST_INTERNAL=unknown-host.example.com
385
- HOST_CANONICAL=unknown-host.example.com
406
+ HOSTNAME_INTERNAL=unknown-host.example.com
386
407
  ROOT_URL_INTERNAL=https://unknown-host.example.com
387
- APP_STORE_CONNECT_API_KEY_CONTENT=$CL_review_app_APP_STORE_CONNECT_API_KEY_CONTENT
388
- APP_STORE_CONNECT_ISSUER_ID=$CL_review_app_APP_STORE_CONNECT_ISSUER_ID
389
- APP_STORE_CONNECT_API_KEY_ID=$CL_review_app_APP_STORE_CONNECT_API_KEY_ID
390
- GRAPHQL_URL=https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql
391
- _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
408
+ APP_STORE_CONNECT_API_KEY_CONTENT=$(printf %s "$CL_review_app_APP_STORE_CONNECT_API_KEY_CONTENT" | escapeForDotEnv)
409
+ APP_STORE_CONNECT_ISSUER_ID=$(printf %s "$CL_review_app_APP_STORE_CONNECT_ISSUER_ID" | escapeForDotEnv)
410
+ APP_STORE_CONNECT_API_KEY_ID=$(printf %s "$CL_review_app_APP_STORE_CONNECT_API_KEY_ID" | escapeForDotEnv)
411
+ GRAPHQL_URL=$(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql" | escapeForDotEnv)
412
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
392
413
  EOF
393
- - echo -e "\\e[0Ksection_end:$(date +%s):write-dotenv-app\\r\\e[0K"
414
+ - collapseable_section_end "write-dotenv-app"
394
415
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > app/__build_info.json
395
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
416
+ - collapseable_section_start "nodeinstall" "Ensure node version"
396
417
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
397
418
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
398
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
419
+ - collapseable_section_end "nodeinstall"
399
420
  - cd app
400
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
421
+ - collapseable_section_start "nodeinstall" "Ensure node version"
401
422
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
402
423
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
403
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
404
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
424
+ - collapseable_section_end "nodeinstall"
425
+ - collapseable_section_start "yarninstall" "Yarn install"
405
426
  - yarn install --immutable
406
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
427
+ - collapseable_section_end "yarninstall"
407
428
  - bundle config set --local path 'vendor/ruby'
408
429
  - gem install bundler
409
430
  - bundle install
@@ -418,10 +439,6 @@ app 🧪 test:
418
439
  policy: pull-push
419
440
  paths:
420
441
  - app/node_modules
421
- - key: app-next-cache
422
- policy: pull-push
423
- paths:
424
- - app/.next/cache
425
442
  - key:
426
443
  files:
427
444
  - app/Gemfile.lock
@@ -448,8 +465,8 @@ app 🧪 test:
448
465
  image: aquasec/trivy:0.38.3
449
466
  variables: {}
450
467
  script:
451
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
452
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
468
+ - collapseable_section_start "injectvars" "Injecting variables"
469
+ - collapseable_section_end "injectvars"
453
470
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" app
454
471
  artifacts:
455
472
  paths:
@@ -470,26 +487,25 @@ app 🧪 test:
470
487
  KUBERNETES_MEMORY_REQUEST: 200Mi
471
488
  KUBERNETES_MEMORY_LIMIT: 400Mi
472
489
  script:
473
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
490
+ - collapseable_section_start "injectvars" "Injecting variables"
474
491
  - export ENV_SHORT="review"
475
492
  - export APP_DIR="app"
476
493
  - export ENV_TYPE="review"
477
494
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
478
495
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
479
496
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
480
- - export HOST="unknown-host.example.com"
497
+ - export HOSTNAME="unknown-host.example.com"
481
498
  - export ROOT_URL="https://unknown-host.example.com"
482
- - export HOST_INTERNAL="unknown-host.example.com"
483
- - export HOST_CANONICAL="unknown-host.example.com"
499
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
484
500
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
485
501
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_review_app_APP_STORE_CONNECT_API_KEY_CONTENT"
486
502
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_review_app_APP_STORE_CONNECT_ISSUER_ID"
487
503
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_review_app_APP_STORE_CONNECT_API_KEY_ID"
488
504
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
489
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
505
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
490
506
  - export LC_A="L=en_US.UTF-8"
491
507
  - export LANG="en_US.UTF-8"
492
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
508
+ - collapseable_section_end "injectvars"
493
509
  - cd app
494
510
  - bundle config set --local path 'vendor/ruby'
495
511
  - gem install bundler
@@ -531,57 +547,55 @@ app 🧪 test:
531
547
  KUBERNETES_MEMORY_REQUEST: 1Gi
532
548
  KUBERNETES_MEMORY_LIMIT: 4Gi
533
549
  script:
534
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
550
+ - collapseable_section_start "injectvars" "Injecting variables"
535
551
  - export ENV_SHORT="stage"
536
552
  - export APP_DIR="app"
537
553
  - export ENV_TYPE="stage"
538
554
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
539
555
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
540
556
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
541
- - export HOST="unknown-host.example.com"
557
+ - export HOSTNAME="unknown-host.example.com"
542
558
  - export ROOT_URL="https://unknown-host.example.com"
543
- - export HOST_INTERNAL="unknown-host.example.com"
544
- - export HOST_CANONICAL="unknown-host.example.com"
559
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
545
560
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
546
561
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_stage_app_APP_STORE_CONNECT_API_KEY_CONTENT"
547
562
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_stage_app_APP_STORE_CONNECT_ISSUER_ID"
548
563
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_stage_app_APP_STORE_CONNECT_API_KEY_ID"
549
564
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
550
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
565
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
551
566
  - export LC_A="L=en_US.UTF-8"
552
567
  - export LANG="en_US.UTF-8"
553
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
554
- - echo -e "\\e[0Ksection_start:$(date +%s):write-dotenv-app[collapsed=true]\\r\\e[0Kwrite dot env"
568
+ - collapseable_section_end "injectvars"
569
+ - collapseable_section_start "write-dotenv-app" "write dot env for app"
555
570
  - |-
556
571
  cat <<EOF > app/.env
557
572
  ENV_SHORT=stage
558
573
  APP_DIR=app
559
574
  ENV_TYPE=stage
560
- HOST=unknown-host.example.com
575
+ HOSTNAME=unknown-host.example.com
561
576
  ROOT_URL=https://unknown-host.example.com
562
- HOST_INTERNAL=unknown-host.example.com
563
- HOST_CANONICAL=unknown-host.example.com
577
+ HOSTNAME_INTERNAL=unknown-host.example.com
564
578
  ROOT_URL_INTERNAL=https://unknown-host.example.com
565
- APP_STORE_CONNECT_API_KEY_CONTENT=$CL_stage_app_APP_STORE_CONNECT_API_KEY_CONTENT
566
- APP_STORE_CONNECT_ISSUER_ID=$CL_stage_app_APP_STORE_CONNECT_ISSUER_ID
567
- APP_STORE_CONNECT_API_KEY_ID=$CL_stage_app_APP_STORE_CONNECT_API_KEY_ID
568
- GRAPHQL_URL=https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql
569
- _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
579
+ APP_STORE_CONNECT_API_KEY_CONTENT=$(printf %s "$CL_stage_app_APP_STORE_CONNECT_API_KEY_CONTENT" | escapeForDotEnv)
580
+ APP_STORE_CONNECT_ISSUER_ID=$(printf %s "$CL_stage_app_APP_STORE_CONNECT_ISSUER_ID" | escapeForDotEnv)
581
+ APP_STORE_CONNECT_API_KEY_ID=$(printf %s "$CL_stage_app_APP_STORE_CONNECT_API_KEY_ID" | escapeForDotEnv)
582
+ GRAPHQL_URL=$(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql" | escapeForDotEnv)
583
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
570
584
  EOF
571
- - echo -e "\\e[0Ksection_end:$(date +%s):write-dotenv-app\\r\\e[0K"
585
+ - collapseable_section_end "write-dotenv-app"
572
586
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > app/__build_info.json
573
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
587
+ - collapseable_section_start "nodeinstall" "Ensure node version"
574
588
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
575
589
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
576
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
590
+ - collapseable_section_end "nodeinstall"
577
591
  - cd app
578
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
592
+ - collapseable_section_start "nodeinstall" "Ensure node version"
579
593
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
580
594
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
581
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
582
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
595
+ - collapseable_section_end "nodeinstall"
596
+ - collapseable_section_start "yarninstall" "Yarn install"
583
597
  - yarn install --immutable
584
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
598
+ - collapseable_section_end "yarninstall"
585
599
  - bundle config set --local path 'vendor/ruby'
586
600
  - gem install bundler
587
601
  - bundle install
@@ -596,10 +610,6 @@ app 🧪 test:
596
610
  policy: pull-push
597
611
  paths:
598
612
  - app/node_modules
599
- - key: app-next-cache
600
- policy: pull-push
601
- paths:
602
- - app/.next/cache
603
613
  - key:
604
614
  files:
605
615
  - app/Gemfile.lock
@@ -626,8 +636,8 @@ app 🧪 test:
626
636
  image: aquasec/trivy:0.38.3
627
637
  variables: {}
628
638
  script:
629
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
630
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
639
+ - collapseable_section_start "injectvars" "Injecting variables"
640
+ - collapseable_section_end "injectvars"
631
641
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" app
632
642
  artifacts:
633
643
  paths:
@@ -648,26 +658,25 @@ app 🧪 test:
648
658
  KUBERNETES_MEMORY_REQUEST: 200Mi
649
659
  KUBERNETES_MEMORY_LIMIT: 400Mi
650
660
  script:
651
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
661
+ - collapseable_section_start "injectvars" "Injecting variables"
652
662
  - export ENV_SHORT="stage"
653
663
  - export APP_DIR="app"
654
664
  - export ENV_TYPE="stage"
655
665
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
656
666
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
657
667
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
658
- - export HOST="unknown-host.example.com"
668
+ - export HOSTNAME="unknown-host.example.com"
659
669
  - export ROOT_URL="https://unknown-host.example.com"
660
- - export HOST_INTERNAL="unknown-host.example.com"
661
- - export HOST_CANONICAL="unknown-host.example.com"
670
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
662
671
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
663
672
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_stage_app_APP_STORE_CONNECT_API_KEY_CONTENT"
664
673
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_stage_app_APP_STORE_CONNECT_ISSUER_ID"
665
674
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_stage_app_APP_STORE_CONNECT_API_KEY_ID"
666
675
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
667
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
676
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
668
677
  - export LC_A="L=en_US.UTF-8"
669
678
  - export LANG="en_US.UTF-8"
670
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
679
+ - collapseable_section_end "injectvars"
671
680
  - cd app
672
681
  - bundle config set --local path 'vendor/ruby'
673
682
  - gem install bundler
@@ -703,57 +712,55 @@ app 🧪 test:
703
712
  KUBERNETES_MEMORY_REQUEST: 1Gi
704
713
  KUBERNETES_MEMORY_LIMIT: 4Gi
705
714
  script:
706
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
715
+ - collapseable_section_start "injectvars" "Injecting variables"
707
716
  - export ENV_SHORT="prod"
708
717
  - export APP_DIR="app"
709
718
  - export ENV_TYPE="prod"
710
719
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
711
720
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
712
721
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
713
- - export HOST="unknown-host.example.com"
722
+ - export HOSTNAME="unknown-host.example.com"
714
723
  - export ROOT_URL="https://unknown-host.example.com"
715
- - export HOST_INTERNAL="unknown-host.example.com"
716
- - export HOST_CANONICAL="unknown-host.example.com"
724
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
717
725
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
718
726
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_prod_app_APP_STORE_CONNECT_API_KEY_CONTENT"
719
727
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_prod_app_APP_STORE_CONNECT_ISSUER_ID"
720
728
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_prod_app_APP_STORE_CONNECT_API_KEY_ID"
721
729
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
722
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
730
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
723
731
  - export LC_A="L=en_US.UTF-8"
724
732
  - export LANG="en_US.UTF-8"
725
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
726
- - echo -e "\\e[0Ksection_start:$(date +%s):write-dotenv-app[collapsed=true]\\r\\e[0Kwrite dot env"
733
+ - collapseable_section_end "injectvars"
734
+ - collapseable_section_start "write-dotenv-app" "write dot env for app"
727
735
  - |-
728
736
  cat <<EOF > app/.env
729
737
  ENV_SHORT=prod
730
738
  APP_DIR=app
731
739
  ENV_TYPE=prod
732
- HOST=unknown-host.example.com
740
+ HOSTNAME=unknown-host.example.com
733
741
  ROOT_URL=https://unknown-host.example.com
734
- HOST_INTERNAL=unknown-host.example.com
735
- HOST_CANONICAL=unknown-host.example.com
742
+ HOSTNAME_INTERNAL=unknown-host.example.com
736
743
  ROOT_URL_INTERNAL=https://unknown-host.example.com
737
- APP_STORE_CONNECT_API_KEY_CONTENT=$CL_prod_app_APP_STORE_CONNECT_API_KEY_CONTENT
738
- APP_STORE_CONNECT_ISSUER_ID=$CL_prod_app_APP_STORE_CONNECT_ISSUER_ID
739
- APP_STORE_CONNECT_API_KEY_ID=$CL_prod_app_APP_STORE_CONNECT_API_KEY_ID
740
- GRAPHQL_URL=https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql
741
- _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
744
+ APP_STORE_CONNECT_API_KEY_CONTENT=$(printf %s "$CL_prod_app_APP_STORE_CONNECT_API_KEY_CONTENT" | escapeForDotEnv)
745
+ APP_STORE_CONNECT_ISSUER_ID=$(printf %s "$CL_prod_app_APP_STORE_CONNECT_ISSUER_ID" | escapeForDotEnv)
746
+ APP_STORE_CONNECT_API_KEY_ID=$(printf %s "$CL_prod_app_APP_STORE_CONNECT_API_KEY_ID" | escapeForDotEnv)
747
+ GRAPHQL_URL=$(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql" | escapeForDotEnv)
748
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","APP_STORE_CONNECT_API_KEY_CONTENT","APP_STORE_CONNECT_ISSUER_ID","APP_STORE_CONNECT_API_KEY_ID","GRAPHQL_URL"]
742
749
  EOF
743
- - echo -e "\\e[0Ksection_end:$(date +%s):write-dotenv-app\\r\\e[0K"
750
+ - collapseable_section_end "write-dotenv-app"
744
751
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > app/__build_info.json
745
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
752
+ - collapseable_section_start "nodeinstall" "Ensure node version"
746
753
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
747
754
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
748
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
755
+ - collapseable_section_end "nodeinstall"
749
756
  - cd app
750
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
757
+ - collapseable_section_start "nodeinstall" "Ensure node version"
751
758
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
752
759
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
753
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
754
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
760
+ - collapseable_section_end "nodeinstall"
761
+ - collapseable_section_start "yarninstall" "Yarn install"
755
762
  - yarn install --immutable
756
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
763
+ - collapseable_section_end "yarninstall"
757
764
  - bundle config set --local path 'vendor/ruby'
758
765
  - gem install bundler
759
766
  - bundle install
@@ -768,10 +775,6 @@ app 🧪 test:
768
775
  policy: pull-push
769
776
  paths:
770
777
  - app/node_modules
771
- - key: app-next-cache
772
- policy: pull-push
773
- paths:
774
- - app/.next/cache
775
778
  - key:
776
779
  files:
777
780
  - app/Gemfile.lock
@@ -798,8 +801,8 @@ app 🧪 test:
798
801
  image: aquasec/trivy:0.38.3
799
802
  variables: {}
800
803
  script:
801
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
802
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
804
+ - collapseable_section_start "injectvars" "Injecting variables"
805
+ - collapseable_section_end "injectvars"
803
806
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" app
804
807
  artifacts:
805
808
  paths:
@@ -820,26 +823,25 @@ app 🧪 test:
820
823
  KUBERNETES_MEMORY_REQUEST: 200Mi
821
824
  KUBERNETES_MEMORY_LIMIT: 400Mi
822
825
  script:
823
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
826
+ - collapseable_section_start "injectvars" "Injecting variables"
824
827
  - export ENV_SHORT="prod"
825
828
  - export APP_DIR="app"
826
829
  - export ENV_TYPE="prod"
827
830
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
828
831
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
829
832
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
830
- - export HOST="unknown-host.example.com"
833
+ - export HOSTNAME="unknown-host.example.com"
831
834
  - export ROOT_URL="https://unknown-host.example.com"
832
- - export HOST_INTERNAL="unknown-host.example.com"
833
- - export HOST_CANONICAL="unknown-host.example.com"
835
+ - export HOSTNAME_INTERNAL="unknown-host.example.com"
834
836
  - export ROOT_URL_INTERNAL="https://unknown-host.example.com"
835
837
  - export APP_STORE_CONNECT_API_KEY_CONTENT="$CL_prod_app_APP_STORE_CONNECT_API_KEY_CONTENT"
836
838
  - export APP_STORE_CONNECT_ISSUER_ID="$CL_prod_app_APP_STORE_CONNECT_ISSUER_ID"
837
839
  - export APP_STORE_CONNECT_API_KEY_ID="$CL_prod_app_APP_STORE_CONNECT_API_KEY_ID"
838
840
  - export GRAPHQL_URL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')/graphql"
839
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
841
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"APP_STORE_CONNECT_API_KEY_CONTENT\\",\\"APP_STORE_CONNECT_ISSUER_ID\\",\\"APP_STORE_CONNECT_API_KEY_ID\\",\\"GRAPHQL_URL\\"]"
840
842
  - export LC_A="L=en_US.UTF-8"
841
843
  - export LANG="en_US.UTF-8"
842
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
844
+ - collapseable_section_end "injectvars"
843
845
  - cd app
844
846
  - bundle config set --local path 'vendor/ruby'
845
847
  - gem install bundler
@@ -873,9 +875,9 @@ api 🛡 audit:
873
875
  KUBERNETES_MEMORY_REQUEST: 1Gi
874
876
  KUBERNETES_MEMORY_LIMIT: 4Gi
875
877
  script:
876
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
878
+ - collapseable_section_start "injectvars" "Injecting variables"
877
879
  - export APP_PATH="api"
878
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
880
+ - collapseable_section_end "injectvars"
879
881
  - cd api
880
882
  - yarn npm audit --environment production
881
883
  rules:
@@ -895,21 +897,21 @@ api 👮 lint:
895
897
  KUBERNETES_MEMORY_REQUEST: 1Gi
896
898
  KUBERNETES_MEMORY_LIMIT: 4Gi
897
899
  script:
898
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
900
+ - collapseable_section_start "injectvars" "Injecting variables"
899
901
  - export APP_PATH="api"
900
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
901
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
902
+ - collapseable_section_end "injectvars"
903
+ - collapseable_section_start "nodeinstall" "Ensure node version"
902
904
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
903
905
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
904
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
906
+ - collapseable_section_end "nodeinstall"
905
907
  - cd api
906
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
908
+ - collapseable_section_start "nodeinstall" "Ensure node version"
907
909
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
908
910
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
909
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
910
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
911
+ - collapseable_section_end "nodeinstall"
912
+ - collapseable_section_start "yarninstall" "Yarn install"
911
913
  - yarn install --immutable
912
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
914
+ - collapseable_section_end "yarninstall"
913
915
  - yarn lint
914
916
  cache:
915
917
  - key: api-yarn
@@ -936,21 +938,21 @@ api 🧪 test:
936
938
  KUBERNETES_MEMORY_REQUEST: 1Gi
937
939
  KUBERNETES_MEMORY_LIMIT: 4Gi
938
940
  script:
939
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
941
+ - collapseable_section_start "injectvars" "Injecting variables"
940
942
  - export APP_PATH="api"
941
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
942
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
943
+ - collapseable_section_end "injectvars"
944
+ - collapseable_section_start "nodeinstall" "Ensure node version"
943
945
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
944
946
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
945
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
947
+ - collapseable_section_end "nodeinstall"
946
948
  - cd api
947
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
949
+ - collapseable_section_start "nodeinstall" "Ensure node version"
948
950
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
949
951
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
950
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
951
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
952
+ - collapseable_section_end "nodeinstall"
953
+ - collapseable_section_start "yarninstall" "Yarn install"
952
954
  - yarn install --immutable
953
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
955
+ - collapseable_section_end "yarninstall"
954
956
  - yarn test
955
957
  cache:
956
958
  - key: api-yarn
@@ -977,37 +979,53 @@ api 🧪 test:
977
979
  KUBERNETES_MEMORY_REQUEST: 1Gi
978
980
  KUBERNETES_MEMORY_LIMIT: 4Gi
979
981
  script:
980
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
982
+ - collapseable_section_start "injectvars" "Injecting variables"
981
983
  - export ENV_SHORT="dev"
982
984
  - export APP_DIR="api"
983
985
  - export ENV_TYPE="dev"
984
986
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
985
987
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
986
988
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
987
- - export HOST="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
989
+ - export HOSTNAME="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
988
990
  - export ROOT_URL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
989
- - export HOST_INTERNAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
990
- - export HOST_CANONICAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
991
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
991
992
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
992
993
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
993
994
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
994
995
  - export GCLOUD_DEPLOY_credentialsKey="$CL_dev_api_GCLOUD_DEPLOY_credentialsKey"
995
996
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix"
996
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
997
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
997
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
998
+ - collapseable_section_end "injectvars"
999
+ - collapseable_section_start "write-dotenv-api" "write dot env for api"
1000
+ - |-
1001
+ cat <<EOF > api/.env
1002
+ ENV_SHORT=dev
1003
+ APP_DIR=api
1004
+ ENV_TYPE=dev
1005
+ HOSTNAME=$(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1006
+ ROOT_URL=$(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1007
+ HOSTNAME_INTERNAL=$(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1008
+ ROOT_URL_INTERNAL=$(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1009
+ DEPLOY_CLOUD_RUN_PROJECT_ID=asdf
1010
+ DEPLOY_CLOUD_RUN_REGION=asia-east1
1011
+ GCLOUD_DEPLOY_credentialsKey=$(printf %s "$CL_dev_api_GCLOUD_DEPLOY_credentialsKey" | escapeForDotEnv)
1012
+ GCLOUD_RUN_canonicalHostSuffix=$(printf %s "$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | escapeForDotEnv)
1013
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1014
+ EOF
1015
+ - collapseable_section_end "write-dotenv-api"
998
1016
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > api/__build_info.json
999
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1017
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1000
1018
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1001
1019
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1002
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1020
+ - collapseable_section_end "nodeinstall"
1003
1021
  - cd api
1004
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1022
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1005
1023
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1006
1024
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1007
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1008
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
1025
+ - collapseable_section_end "nodeinstall"
1026
+ - collapseable_section_start "yarninstall" "Yarn install"
1009
1027
  - yarn install --immutable
1010
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
1028
+ - collapseable_section_end "yarninstall"
1011
1029
  - yarn build
1012
1030
  cache:
1013
1031
  - key: api-yarn
@@ -1018,15 +1036,13 @@ api 🧪 test:
1018
1036
  policy: pull-push
1019
1037
  paths:
1020
1038
  - api/node_modules
1021
- - key: api-next-cache
1022
- policy: pull-push
1023
- paths:
1024
- - api/.next/cache
1025
1039
  artifacts:
1026
1040
  paths:
1027
1041
  - api/__build_info.json
1028
1042
  - api/.next
1029
1043
  - api/dist
1044
+ exclude:
1045
+ - api/.env
1030
1046
  expire_in: 1 day
1031
1047
  when: always
1032
1048
  reports: {}
@@ -1054,7 +1070,7 @@ api 🧪 test:
1054
1070
  KUBERNETES_MEMORY_REQUEST: 1Gi
1055
1071
  KUBERNETES_MEMORY_LIMIT: 2Gi
1056
1072
  script:
1057
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1073
+ - collapseable_section_start "injectvars" "Injecting variables"
1058
1074
  - export APP_DIR="api"
1059
1075
  - export DOCKER_BUILD_CONTEXT="."
1060
1076
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
@@ -1070,20 +1086,20 @@ api 🧪 test:
1070
1086
  COPY --chown=node:node api/yarn.lock /app/api/yarn.lock
1071
1087
  COPY --chown=node:node .yarnrc.yml /app/.yarnrc.yml
1072
1088
  COPY --chown=node:node .yarn /app/.yarn"
1073
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1089
+ - collapseable_section_end "injectvars"
1074
1090
  - ensureNodeDockerfile
1075
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-login[collapsed=true]\\r\\e[0KDocker Login"
1091
+ - collapseable_section_start "docker-login" "Docker Login"
1076
1092
  - gcloud auth activate-service-account --key-file=<(echo "$CL_dev_api_GCLOUD_DEPLOY_credentialsKey")
1077
1093
  - gcloud auth configure-docker asia-east1-docker.pkg.dev
1078
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-login\\r\\e[0K"
1079
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-build[collapsed=true]\\r\\e[0KDocker build"
1094
+ - collapseable_section_end "docker-login"
1095
+ - collapseable_section_start "docker-build" "Docker build"
1080
1096
  - docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile $DOCKER_BUILD_CONTEXT --build-arg BUILDKIT_INLINE_CACHE=1
1081
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-build\\r\\e[0K"
1082
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-push[collapsed=true]\\r\\e[0KDocker push and tag"
1097
+ - collapseable_section_end "docker-build"
1098
+ - collapseable_section_start "docker-push" "Docker push and tag"
1083
1099
  - docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG
1084
1100
  - docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE
1085
1101
  - docker push $DOCKER_CACHE_IMAGE
1086
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-push\\r\\e[0K"
1102
+ - collapseable_section_end "docker-push"
1087
1103
  cache:
1088
1104
  - key: api-yarn
1089
1105
  policy: pull
@@ -1102,8 +1118,8 @@ api 🧪 test:
1102
1118
  image: aquasec/trivy:0.38.3
1103
1119
  variables: {}
1104
1120
  script:
1105
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1106
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1121
+ - collapseable_section_start "injectvars" "Injecting variables"
1122
+ - collapseable_section_end "injectvars"
1107
1123
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" api
1108
1124
  artifacts:
1109
1125
  paths:
@@ -1124,35 +1140,34 @@ api 🧪 test:
1124
1140
  KUBERNETES_MEMORY_REQUEST: 200Mi
1125
1141
  KUBERNETES_MEMORY_LIMIT: 400Mi
1126
1142
  script:
1127
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1143
+ - collapseable_section_start "injectvars" "Injecting variables"
1128
1144
  - export ENV_SHORT="dev"
1129
1145
  - export APP_DIR="api"
1130
1146
  - export ENV_TYPE="dev"
1131
1147
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1132
1148
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1133
1149
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1134
- - export HOST="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1150
+ - export HOSTNAME="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1135
1151
  - export ROOT_URL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1136
- - export HOST_INTERNAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1137
- - export HOST_CANONICAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1152
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1138
1153
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1139
1154
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1140
1155
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1141
1156
  - export GCLOUD_DEPLOY_credentialsKey="$CL_dev_api_GCLOUD_DEPLOY_credentialsKey"
1142
1157
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix"
1143
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1158
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1144
1159
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
1145
1160
  - export DOCKER_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/dev/api"
1146
1161
  - export DOCKER_CACHE_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api"
1147
1162
  - export DOCKER_IMAGE_TAG="$CI_COMMIT_SHA"
1148
1163
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1149
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1150
- - echo -e "\\e[0Ksection_start:$(date +%s):prepare[collapsed=true]\\r\\e[0KPrepare..."
1164
+ - collapseable_section_end "injectvars"
1165
+ - collapseable_section_start "prepare" "Prepare..."
1151
1166
  - gcloud auth activate-service-account --key-file=<(echo "$CL_dev_api_GCLOUD_DEPLOY_credentialsKey")
1152
1167
  - export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe asdf --format="value(projectNumber)")
1153
1168
  - 'echo "GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER"'
1154
- - echo -e "\\e[0Ksection_end:$(date +%s):prepare\\r\\e[0K"
1155
- - echo -e "\\e[0Ksection_start:$(date +%s):writeenvvars[collapsed=true]\\r\\e[0KWrite env vars to file"
1169
+ - collapseable_section_end "prepare"
1170
+ - collapseable_section_start "writeenvvars" "Write env vars to file"
1156
1171
  - |
1157
1172
  cat > ____envvars.yaml <<EOF
1158
1173
  ENV_SHORT: |-
@@ -1162,40 +1177,38 @@ api 🧪 test:
1162
1177
  ENV_TYPE: |-
1163
1178
  dev
1164
1179
  BUILD_INFO_BUILD_ID: |-
1165
- $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed 's/^/ /')
1180
+ $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed '1!s/^/ /')
1166
1181
  BUILD_INFO_BUILD_TIME: |-
1167
- $(printf %s "$CI_JOB_STARTED_AT" | sed 's/^/ /')
1182
+ $(printf %s "$CI_JOB_STARTED_AT" | sed '1!s/^/ /')
1168
1183
  BUILD_INFO_CURRENT_VERSION: |-
1169
- $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed 's/^/ /')
1170
- HOST: |-
1171
- $(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1184
+ $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed '1!s/^/ /')
1185
+ HOSTNAME: |-
1186
+ $(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1172
1187
  ROOT_URL: |-
1173
- $(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1174
- HOST_INTERNAL: |-
1175
- $(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1176
- HOST_CANONICAL: |-
1177
- $(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1188
+ $(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1189
+ HOSTNAME_INTERNAL: |-
1190
+ $(printf %s "$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1178
1191
  ROOT_URL_INTERNAL: |-
1179
- $(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1192
+ $(printf %s "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1180
1193
  DEPLOY_CLOUD_RUN_PROJECT_ID: |-
1181
1194
  asdf
1182
1195
  DEPLOY_CLOUD_RUN_REGION: |-
1183
1196
  asia-east1
1184
1197
  GCLOUD_RUN_canonicalHostSuffix: |-
1185
- $(printf %s "$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | sed 's/^/ /')
1198
+ $(printf %s "$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | sed '1!s/^/ /')
1186
1199
  _ALL_ENV_VAR_KEYS: |-
1187
- ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1200
+ ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1188
1201
 
1189
1202
  EOF
1190
- - echo -e "\\e[0Ksection_end:$(date +%s):writeenvvars\\r\\e[0K"
1191
- - echo -e "\\e[0Ksection_start:$(date +%s):deploy[collapsed=true]\\r\\e[0KDeploy to cloud run"
1203
+ - collapseable_section_end "writeenvvars"
1204
+ - collapseable_section_start "deploy" "Deploy to cloud run"
1192
1205
  - gcloud run deploy pan-test-app-dev-api --command="yarn,start" --image=asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/dev/api:$DOCKER_IMAGE_TAG --project=asdf --region=asia-east1 --labels=customer-name=pan,component-name=api,app-name=test-app,env-type=dev,env-name=dev,build-type=node,cloud-run-service-name=pan-test-app-dev-api --env-vars-file=____envvars.yaml --min-instances=0 --max-instances=100 --cpu-throttling --allow-unauthenticated --ingress=all --cpu-boost
1193
- - echo -e "\\e[0Ksection_end:$(date +%s):deploy\\r\\e[0K"
1194
- - echo -e "\\e[0Ksection_start:$(date +%s):cleanup[collapsed=true]\\r\\e[0KCleanup"
1206
+ - collapseable_section_end "deploy"
1207
+ - collapseable_section_start "cleanup" "Cleanup"
1195
1208
  - gcloud run revisions list --project=asdf --region=asia-east1 --service=pan-test-app-dev-api --limit=unlimited --sort-by=metadata.creationTimestamp --format="value(name)" --filter='(status.conditions.status=False OR status.conditions.status=Unknown)' | while read -r revisionname; do gcloud run revisions delete --project=asdf --region=asia-east1 --quiet $revisionname ; done
1196
1209
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/dev/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/dev/api@$version --quiet --delete-tags; done
1197
1210
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api@$version --quiet --delete-tags; done
1198
- - echo -e "\\e[0Ksection_end:$(date +%s):cleanup\\r\\e[0K"
1211
+ - collapseable_section_end "cleanup"
1199
1212
  - echo 'Uploading SBOM to Dependency Track'
1200
1213
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" "__sbom.json" vex.json || true
1201
1214
  - echo "CL_GITLAB_ENVIRONMENT_URL=https://$(printf %s "pan-test-app-dev-api-$CL_dev_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" >> gitlab_environment.env
@@ -1237,9 +1250,9 @@ api 🧪 test:
1237
1250
  KUBERNETES_MEMORY_LIMIT: 400Mi
1238
1251
  GIT_STRATEGY: none
1239
1252
  script:
1240
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1253
+ - collapseable_section_start "injectvars" "Injecting variables"
1241
1254
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1242
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1255
+ - collapseable_section_end "injectvars"
1243
1256
  - set +e
1244
1257
  - gcloud auth activate-service-account --key-file=<(echo "$CL_dev_api_GCLOUD_DEPLOY_credentialsKey")
1245
1258
  - gcloud run services delete pan-test-app-dev-api --project=asdf --region=asia-east1
@@ -1275,37 +1288,53 @@ api 🧪 test:
1275
1288
  KUBERNETES_MEMORY_REQUEST: 1Gi
1276
1289
  KUBERNETES_MEMORY_LIMIT: 4Gi
1277
1290
  script:
1278
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1291
+ - collapseable_section_start "injectvars" "Injecting variables"
1279
1292
  - export ENV_SHORT="review"
1280
1293
  - export APP_DIR="api"
1281
1294
  - export ENV_TYPE="review"
1282
1295
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1283
1296
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1284
1297
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1285
- - export HOST="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1298
+ - export HOSTNAME="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1286
1299
  - export ROOT_URL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1287
- - export HOST_INTERNAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1288
- - export HOST_CANONICAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1300
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1289
1301
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1290
1302
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1291
1303
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1292
1304
  - export GCLOUD_DEPLOY_credentialsKey="$CL_review_api_GCLOUD_DEPLOY_credentialsKey"
1293
1305
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_review_api_GCLOUD_RUN_canonicalHostSuffix"
1294
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1295
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1306
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1307
+ - collapseable_section_end "injectvars"
1308
+ - collapseable_section_start "write-dotenv-api" "write dot env for api"
1309
+ - |-
1310
+ cat <<EOF > api/.env
1311
+ ENV_SHORT=review
1312
+ APP_DIR=api
1313
+ ENV_TYPE=review
1314
+ HOSTNAME=$(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1315
+ ROOT_URL=$(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1316
+ HOSTNAME_INTERNAL=$(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1317
+ ROOT_URL_INTERNAL=$(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1318
+ DEPLOY_CLOUD_RUN_PROJECT_ID=asdf
1319
+ DEPLOY_CLOUD_RUN_REGION=asia-east1
1320
+ GCLOUD_DEPLOY_credentialsKey=$(printf %s "$CL_review_api_GCLOUD_DEPLOY_credentialsKey" | escapeForDotEnv)
1321
+ GCLOUD_RUN_canonicalHostSuffix=$(printf %s "$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | escapeForDotEnv)
1322
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1323
+ EOF
1324
+ - collapseable_section_end "write-dotenv-api"
1296
1325
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > api/__build_info.json
1297
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1326
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1298
1327
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1299
1328
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1300
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1329
+ - collapseable_section_end "nodeinstall"
1301
1330
  - cd api
1302
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1331
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1303
1332
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1304
1333
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1305
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1306
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
1334
+ - collapseable_section_end "nodeinstall"
1335
+ - collapseable_section_start "yarninstall" "Yarn install"
1307
1336
  - yarn install --immutable
1308
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
1337
+ - collapseable_section_end "yarninstall"
1309
1338
  - yarn build
1310
1339
  cache:
1311
1340
  - key: api-yarn
@@ -1316,15 +1345,13 @@ api 🧪 test:
1316
1345
  policy: pull-push
1317
1346
  paths:
1318
1347
  - api/node_modules
1319
- - key: api-next-cache
1320
- policy: pull-push
1321
- paths:
1322
- - api/.next/cache
1323
1348
  artifacts:
1324
1349
  paths:
1325
1350
  - api/__build_info.json
1326
1351
  - api/.next
1327
1352
  - api/dist
1353
+ exclude:
1354
+ - api/.env
1328
1355
  expire_in: 1 day
1329
1356
  when: always
1330
1357
  reports: {}
@@ -1350,7 +1377,7 @@ api 🧪 test:
1350
1377
  KUBERNETES_MEMORY_REQUEST: 1Gi
1351
1378
  KUBERNETES_MEMORY_LIMIT: 2Gi
1352
1379
  script:
1353
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1380
+ - collapseable_section_start "injectvars" "Injecting variables"
1354
1381
  - export APP_DIR="api"
1355
1382
  - export DOCKER_BUILD_CONTEXT="."
1356
1383
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
@@ -1366,20 +1393,20 @@ api 🧪 test:
1366
1393
  COPY --chown=node:node api/yarn.lock /app/api/yarn.lock
1367
1394
  COPY --chown=node:node .yarnrc.yml /app/.yarnrc.yml
1368
1395
  COPY --chown=node:node .yarn /app/.yarn"
1369
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1396
+ - collapseable_section_end "injectvars"
1370
1397
  - ensureNodeDockerfile
1371
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-login[collapsed=true]\\r\\e[0KDocker Login"
1398
+ - collapseable_section_start "docker-login" "Docker Login"
1372
1399
  - gcloud auth activate-service-account --key-file=<(echo "$CL_review_api_GCLOUD_DEPLOY_credentialsKey")
1373
1400
  - gcloud auth configure-docker asia-east1-docker.pkg.dev
1374
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-login\\r\\e[0K"
1375
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-build[collapsed=true]\\r\\e[0KDocker build"
1401
+ - collapseable_section_end "docker-login"
1402
+ - collapseable_section_start "docker-build" "Docker build"
1376
1403
  - docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile $DOCKER_BUILD_CONTEXT --build-arg BUILDKIT_INLINE_CACHE=1
1377
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-build\\r\\e[0K"
1378
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-push[collapsed=true]\\r\\e[0KDocker push and tag"
1404
+ - collapseable_section_end "docker-build"
1405
+ - collapseable_section_start "docker-push" "Docker push and tag"
1379
1406
  - docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG
1380
1407
  - docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE
1381
1408
  - docker push $DOCKER_CACHE_IMAGE
1382
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-push\\r\\e[0K"
1409
+ - collapseable_section_end "docker-push"
1383
1410
  cache:
1384
1411
  - key: api-yarn
1385
1412
  policy: pull
@@ -1396,8 +1423,8 @@ api 🧪 test:
1396
1423
  image: aquasec/trivy:0.38.3
1397
1424
  variables: {}
1398
1425
  script:
1399
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1400
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1426
+ - collapseable_section_start "injectvars" "Injecting variables"
1427
+ - collapseable_section_end "injectvars"
1401
1428
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" api
1402
1429
  artifacts:
1403
1430
  paths:
@@ -1416,35 +1443,34 @@ api 🧪 test:
1416
1443
  KUBERNETES_MEMORY_REQUEST: 200Mi
1417
1444
  KUBERNETES_MEMORY_LIMIT: 400Mi
1418
1445
  script:
1419
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1446
+ - collapseable_section_start "injectvars" "Injecting variables"
1420
1447
  - export ENV_SHORT="review"
1421
1448
  - export APP_DIR="api"
1422
1449
  - export ENV_TYPE="review"
1423
1450
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1424
1451
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1425
1452
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1426
- - export HOST="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1453
+ - export HOSTNAME="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1427
1454
  - export ROOT_URL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1428
- - export HOST_INTERNAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1429
- - export HOST_CANONICAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1455
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1430
1456
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1431
1457
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1432
1458
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1433
1459
  - export GCLOUD_DEPLOY_credentialsKey="$CL_review_api_GCLOUD_DEPLOY_credentialsKey"
1434
1460
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_review_api_GCLOUD_RUN_canonicalHostSuffix"
1435
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1461
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1436
1462
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
1437
1463
  - export DOCKER_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/review/api/$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })"
1438
1464
  - export DOCKER_CACHE_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api"
1439
1465
  - export DOCKER_IMAGE_TAG="$CI_COMMIT_SHA"
1440
1466
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1441
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1442
- - echo -e "\\e[0Ksection_start:$(date +%s):prepare[collapsed=true]\\r\\e[0KPrepare..."
1467
+ - collapseable_section_end "injectvars"
1468
+ - collapseable_section_start "prepare" "Prepare..."
1443
1469
  - gcloud auth activate-service-account --key-file=<(echo "$CL_review_api_GCLOUD_DEPLOY_credentialsKey")
1444
1470
  - export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe asdf --format="value(projectNumber)")
1445
1471
  - 'echo "GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER"'
1446
- - echo -e "\\e[0Ksection_end:$(date +%s):prepare\\r\\e[0K"
1447
- - echo -e "\\e[0Ksection_start:$(date +%s):writeenvvars[collapsed=true]\\r\\e[0KWrite env vars to file"
1472
+ - collapseable_section_end "prepare"
1473
+ - collapseable_section_start "writeenvvars" "Write env vars to file"
1448
1474
  - |
1449
1475
  cat > ____envvars.yaml <<EOF
1450
1476
  ENV_SHORT: |-
@@ -1454,43 +1480,41 @@ api 🧪 test:
1454
1480
  ENV_TYPE: |-
1455
1481
  review
1456
1482
  BUILD_INFO_BUILD_ID: |-
1457
- $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed 's/^/ /')
1483
+ $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed '1!s/^/ /')
1458
1484
  BUILD_INFO_BUILD_TIME: |-
1459
- $(printf %s "$CI_JOB_STARTED_AT" | sed 's/^/ /')
1485
+ $(printf %s "$CI_JOB_STARTED_AT" | sed '1!s/^/ /')
1460
1486
  BUILD_INFO_CURRENT_VERSION: |-
1461
- $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed 's/^/ /')
1462
- HOST: |-
1463
- $(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1487
+ $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed '1!s/^/ /')
1488
+ HOSTNAME: |-
1489
+ $(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1464
1490
  ROOT_URL: |-
1465
- $(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1466
- HOST_INTERNAL: |-
1467
- $(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1468
- HOST_CANONICAL: |-
1469
- $(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1491
+ $(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1492
+ HOSTNAME_INTERNAL: |-
1493
+ $(printf %s "$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1470
1494
  ROOT_URL_INTERNAL: |-
1471
- $(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1495
+ $(printf %s "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1472
1496
  DEPLOY_CLOUD_RUN_PROJECT_ID: |-
1473
1497
  asdf
1474
1498
  DEPLOY_CLOUD_RUN_REGION: |-
1475
1499
  asia-east1
1476
1500
  GCLOUD_RUN_canonicalHostSuffix: |-
1477
- $(printf %s "$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | sed 's/^/ /')
1501
+ $(printf %s "$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | sed '1!s/^/ /')
1478
1502
  _ALL_ENV_VAR_KEYS: |-
1479
- ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1503
+ ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1480
1504
 
1481
1505
  EOF
1482
- - echo -e "\\e[0Ksection_end:$(date +%s):writeenvvars\\r\\e[0K"
1483
- - echo -e "\\e[0Ksection_start:$(date +%s):deploy[collapsed=true]\\r\\e[0KDeploy to cloud run"
1506
+ - collapseable_section_end "writeenvvars"
1507
+ - collapseable_section_start "deploy" "Deploy to cloud run"
1484
1508
  - gcloud run deploy $(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api" | awk '{print tolower($0)}') --command="yarn,start" --image=asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/review/api/$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; }):$DOCKER_IMAGE_TAG --project=asdf --region=asia-east1 --labels=customer-name=pan,component-name=api,app-name=test-app,env-type=review,env-name=review,build-type=node,cloud-run-service-name=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api" | awk '{print tolower($0)}') --env-vars-file=____envvars.yaml --min-instances=0 --max-instances=100 --cpu-throttling --allow-unauthenticated --ingress=all --cpu-boost
1485
- - echo -e "\\e[0Ksection_end:$(date +%s):deploy\\r\\e[0K"
1486
- - echo -e "\\e[0Ksection_start:$(date +%s):cleanup[collapsed=true]\\r\\e[0KCleanup"
1509
+ - collapseable_section_end "deploy"
1510
+ - collapseable_section_start "cleanup" "Cleanup"
1487
1511
  - gcloud run revisions list --project=asdf --region=asia-east1 --service=$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api" | awk '{print tolower($0)}') --limit=unlimited --sort-by=metadata.creationTimestamp --format="value(name)" --filter='(status.conditions.status=False OR status.conditions.status=Unknown)' | while read -r revisionname; do gcloud run revisions delete --project=asdf --region=asia-east1 --quiet $revisionname ; done
1488
1512
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/review/api/$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; }) --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/review/api/$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })@$version --quiet --delete-tags; done
1489
1513
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api@$version --quiet --delete-tags; done
1490
1514
  - set +e
1491
1515
  - gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/review/api --quiet --delete-tags
1492
1516
  - set -e
1493
- - echo -e "\\e[0Ksection_end:$(date +%s):cleanup\\r\\e[0K"
1517
+ - collapseable_section_end "cleanup"
1494
1518
  - echo 'Uploading SBOM to Dependency Track'
1495
1519
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" "__sbom.json" vex.json || true
1496
1520
  - echo "CL_GITLAB_ENVIRONMENT_URL=https://$(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api-$CL_review_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" >> gitlab_environment.env
@@ -1530,9 +1554,9 @@ api 🧪 test:
1530
1554
  KUBERNETES_MEMORY_LIMIT: 400Mi
1531
1555
  GIT_STRATEGY: none
1532
1556
  script:
1533
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1557
+ - collapseable_section_start "injectvars" "Injecting variables"
1534
1558
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1535
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1559
+ - collapseable_section_end "injectvars"
1536
1560
  - set +e
1537
1561
  - gcloud auth activate-service-account --key-file=<(echo "$CL_review_api_GCLOUD_DEPLOY_credentialsKey")
1538
1562
  - gcloud run services delete $(printf %s "pan-test-app-review-$([ -n "$CI_MERGE_REQUEST_IID" ] && echo "mr$CI_MERGE_REQUEST_IID" || { [ -n "$CI_COMMIT_REF_SLUG" ] && echo "$CI_COMMIT_REF_SLUG" || echo "unknown"; })-api" | awk '{print tolower($0)}') --project=asdf --region=asia-east1
@@ -1569,37 +1593,53 @@ api 🧪 test:
1569
1593
  KUBERNETES_MEMORY_REQUEST: 1Gi
1570
1594
  KUBERNETES_MEMORY_LIMIT: 4Gi
1571
1595
  script:
1572
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1596
+ - collapseable_section_start "injectvars" "Injecting variables"
1573
1597
  - export ENV_SHORT="stage"
1574
1598
  - export APP_DIR="api"
1575
1599
  - export ENV_TYPE="stage"
1576
1600
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1577
1601
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1578
1602
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1579
- - export HOST="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1603
+ - export HOSTNAME="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1580
1604
  - export ROOT_URL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1581
- - export HOST_INTERNAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1582
- - export HOST_CANONICAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1605
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1583
1606
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1584
1607
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1585
1608
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1586
1609
  - export GCLOUD_DEPLOY_credentialsKey="$CL_stage_api_GCLOUD_DEPLOY_credentialsKey"
1587
1610
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix"
1588
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1589
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1611
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1612
+ - collapseable_section_end "injectvars"
1613
+ - collapseable_section_start "write-dotenv-api" "write dot env for api"
1614
+ - |-
1615
+ cat <<EOF > api/.env
1616
+ ENV_SHORT=stage
1617
+ APP_DIR=api
1618
+ ENV_TYPE=stage
1619
+ HOSTNAME=$(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1620
+ ROOT_URL=$(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1621
+ HOSTNAME_INTERNAL=$(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1622
+ ROOT_URL_INTERNAL=$(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1623
+ DEPLOY_CLOUD_RUN_PROJECT_ID=asdf
1624
+ DEPLOY_CLOUD_RUN_REGION=asia-east1
1625
+ GCLOUD_DEPLOY_credentialsKey=$(printf %s "$CL_stage_api_GCLOUD_DEPLOY_credentialsKey" | escapeForDotEnv)
1626
+ GCLOUD_RUN_canonicalHostSuffix=$(printf %s "$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | escapeForDotEnv)
1627
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1628
+ EOF
1629
+ - collapseable_section_end "write-dotenv-api"
1590
1630
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > api/__build_info.json
1591
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1631
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1592
1632
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1593
1633
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1594
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1634
+ - collapseable_section_end "nodeinstall"
1595
1635
  - cd api
1596
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1636
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1597
1637
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1598
1638
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1599
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1600
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
1639
+ - collapseable_section_end "nodeinstall"
1640
+ - collapseable_section_start "yarninstall" "Yarn install"
1601
1641
  - yarn install --immutable
1602
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
1642
+ - collapseable_section_end "yarninstall"
1603
1643
  - yarn build
1604
1644
  cache:
1605
1645
  - key: api-yarn
@@ -1610,15 +1650,13 @@ api 🧪 test:
1610
1650
  policy: pull-push
1611
1651
  paths:
1612
1652
  - api/node_modules
1613
- - key: api-next-cache
1614
- policy: pull-push
1615
- paths:
1616
- - api/.next/cache
1617
1653
  artifacts:
1618
1654
  paths:
1619
1655
  - api/__build_info.json
1620
1656
  - api/.next
1621
1657
  - api/dist
1658
+ exclude:
1659
+ - api/.env
1622
1660
  expire_in: 1 day
1623
1661
  when: always
1624
1662
  reports: {}
@@ -1644,7 +1682,7 @@ api 🧪 test:
1644
1682
  KUBERNETES_MEMORY_REQUEST: 1Gi
1645
1683
  KUBERNETES_MEMORY_LIMIT: 2Gi
1646
1684
  script:
1647
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1685
+ - collapseable_section_start "injectvars" "Injecting variables"
1648
1686
  - export APP_DIR="api"
1649
1687
  - export DOCKER_BUILD_CONTEXT="."
1650
1688
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
@@ -1660,20 +1698,20 @@ api 🧪 test:
1660
1698
  COPY --chown=node:node api/yarn.lock /app/api/yarn.lock
1661
1699
  COPY --chown=node:node .yarnrc.yml /app/.yarnrc.yml
1662
1700
  COPY --chown=node:node .yarn /app/.yarn"
1663
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1701
+ - collapseable_section_end "injectvars"
1664
1702
  - ensureNodeDockerfile
1665
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-login[collapsed=true]\\r\\e[0KDocker Login"
1703
+ - collapseable_section_start "docker-login" "Docker Login"
1666
1704
  - gcloud auth activate-service-account --key-file=<(echo "$CL_stage_api_GCLOUD_DEPLOY_credentialsKey")
1667
1705
  - gcloud auth configure-docker asia-east1-docker.pkg.dev
1668
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-login\\r\\e[0K"
1669
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-build[collapsed=true]\\r\\e[0KDocker build"
1706
+ - collapseable_section_end "docker-login"
1707
+ - collapseable_section_start "docker-build" "Docker build"
1670
1708
  - docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile $DOCKER_BUILD_CONTEXT --build-arg BUILDKIT_INLINE_CACHE=1
1671
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-build\\r\\e[0K"
1672
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-push[collapsed=true]\\r\\e[0KDocker push and tag"
1709
+ - collapseable_section_end "docker-build"
1710
+ - collapseable_section_start "docker-push" "Docker push and tag"
1673
1711
  - docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG
1674
1712
  - docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE
1675
1713
  - docker push $DOCKER_CACHE_IMAGE
1676
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-push\\r\\e[0K"
1714
+ - collapseable_section_end "docker-push"
1677
1715
  cache:
1678
1716
  - key: api-yarn
1679
1717
  policy: pull
@@ -1690,8 +1728,8 @@ api 🧪 test:
1690
1728
  image: aquasec/trivy:0.38.3
1691
1729
  variables: {}
1692
1730
  script:
1693
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1694
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1731
+ - collapseable_section_start "injectvars" "Injecting variables"
1732
+ - collapseable_section_end "injectvars"
1695
1733
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" api
1696
1734
  artifacts:
1697
1735
  paths:
@@ -1710,35 +1748,34 @@ api 🧪 test:
1710
1748
  KUBERNETES_MEMORY_REQUEST: 200Mi
1711
1749
  KUBERNETES_MEMORY_LIMIT: 400Mi
1712
1750
  script:
1713
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1751
+ - collapseable_section_start "injectvars" "Injecting variables"
1714
1752
  - export ENV_SHORT="stage"
1715
1753
  - export APP_DIR="api"
1716
1754
  - export ENV_TYPE="stage"
1717
1755
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1718
1756
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1719
1757
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1720
- - export HOST="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1758
+ - export HOSTNAME="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1721
1759
  - export ROOT_URL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1722
- - export HOST_INTERNAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1723
- - export HOST_CANONICAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1760
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1724
1761
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1725
1762
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1726
1763
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1727
1764
  - export GCLOUD_DEPLOY_credentialsKey="$CL_stage_api_GCLOUD_DEPLOY_credentialsKey"
1728
1765
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix"
1729
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1766
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1730
1767
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
1731
1768
  - export DOCKER_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/stage/api"
1732
1769
  - export DOCKER_CACHE_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api"
1733
1770
  - export DOCKER_IMAGE_TAG="$CI_COMMIT_SHA"
1734
1771
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1735
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1736
- - echo -e "\\e[0Ksection_start:$(date +%s):prepare[collapsed=true]\\r\\e[0KPrepare..."
1772
+ - collapseable_section_end "injectvars"
1773
+ - collapseable_section_start "prepare" "Prepare..."
1737
1774
  - gcloud auth activate-service-account --key-file=<(echo "$CL_stage_api_GCLOUD_DEPLOY_credentialsKey")
1738
1775
  - export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe asdf --format="value(projectNumber)")
1739
1776
  - 'echo "GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER"'
1740
- - echo -e "\\e[0Ksection_end:$(date +%s):prepare\\r\\e[0K"
1741
- - echo -e "\\e[0Ksection_start:$(date +%s):writeenvvars[collapsed=true]\\r\\e[0KWrite env vars to file"
1777
+ - collapseable_section_end "prepare"
1778
+ - collapseable_section_start "writeenvvars" "Write env vars to file"
1742
1779
  - |
1743
1780
  cat > ____envvars.yaml <<EOF
1744
1781
  ENV_SHORT: |-
@@ -1748,40 +1785,38 @@ api 🧪 test:
1748
1785
  ENV_TYPE: |-
1749
1786
  stage
1750
1787
  BUILD_INFO_BUILD_ID: |-
1751
- $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed 's/^/ /')
1788
+ $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed '1!s/^/ /')
1752
1789
  BUILD_INFO_BUILD_TIME: |-
1753
- $(printf %s "$CI_JOB_STARTED_AT" | sed 's/^/ /')
1790
+ $(printf %s "$CI_JOB_STARTED_AT" | sed '1!s/^/ /')
1754
1791
  BUILD_INFO_CURRENT_VERSION: |-
1755
- $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed 's/^/ /')
1756
- HOST: |-
1757
- $(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1792
+ $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed '1!s/^/ /')
1793
+ HOSTNAME: |-
1794
+ $(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1758
1795
  ROOT_URL: |-
1759
- $(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1760
- HOST_INTERNAL: |-
1761
- $(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1762
- HOST_CANONICAL: |-
1763
- $(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1796
+ $(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1797
+ HOSTNAME_INTERNAL: |-
1798
+ $(printf %s "$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1764
1799
  ROOT_URL_INTERNAL: |-
1765
- $(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
1800
+ $(printf %s "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
1766
1801
  DEPLOY_CLOUD_RUN_PROJECT_ID: |-
1767
1802
  asdf
1768
1803
  DEPLOY_CLOUD_RUN_REGION: |-
1769
1804
  asia-east1
1770
1805
  GCLOUD_RUN_canonicalHostSuffix: |-
1771
- $(printf %s "$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | sed 's/^/ /')
1806
+ $(printf %s "$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | sed '1!s/^/ /')
1772
1807
  _ALL_ENV_VAR_KEYS: |-
1773
- ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1808
+ ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1774
1809
 
1775
1810
  EOF
1776
- - echo -e "\\e[0Ksection_end:$(date +%s):writeenvvars\\r\\e[0K"
1777
- - echo -e "\\e[0Ksection_start:$(date +%s):deploy[collapsed=true]\\r\\e[0KDeploy to cloud run"
1811
+ - collapseable_section_end "writeenvvars"
1812
+ - collapseable_section_start "deploy" "Deploy to cloud run"
1778
1813
  - gcloud run deploy pan-test-app-stage-api --command="yarn,start" --image=asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/stage/api:$DOCKER_IMAGE_TAG --project=asdf --region=asia-east1 --labels=customer-name=pan,component-name=api,app-name=test-app,env-type=stage,env-name=stage,build-type=node,cloud-run-service-name=pan-test-app-stage-api --env-vars-file=____envvars.yaml --min-instances=0 --max-instances=100 --cpu-throttling --allow-unauthenticated --ingress=all --cpu-boost
1779
- - echo -e "\\e[0Ksection_end:$(date +%s):deploy\\r\\e[0K"
1780
- - echo -e "\\e[0Ksection_start:$(date +%s):cleanup[collapsed=true]\\r\\e[0KCleanup"
1814
+ - collapseable_section_end "deploy"
1815
+ - collapseable_section_start "cleanup" "Cleanup"
1781
1816
  - gcloud run revisions list --project=asdf --region=asia-east1 --service=pan-test-app-stage-api --limit=unlimited --sort-by=metadata.creationTimestamp --format="value(name)" --filter='(status.conditions.status=False OR status.conditions.status=Unknown)' | while read -r revisionname; do gcloud run revisions delete --project=asdf --region=asia-east1 --quiet $revisionname ; done
1782
1817
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/stage/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/stage/api@$version --quiet --delete-tags; done
1783
1818
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api@$version --quiet --delete-tags; done
1784
- - echo -e "\\e[0Ksection_end:$(date +%s):cleanup\\r\\e[0K"
1819
+ - collapseable_section_end "cleanup"
1785
1820
  - echo 'Uploading SBOM to Dependency Track'
1786
1821
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" "__sbom.json" vex.json || true
1787
1822
  - echo "CL_GITLAB_ENVIRONMENT_URL=https://$(printf %s "pan-test-app-stage-api-$CL_stage_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" >> gitlab_environment.env
@@ -1814,9 +1849,9 @@ api 🧪 test:
1814
1849
  KUBERNETES_MEMORY_LIMIT: 400Mi
1815
1850
  GIT_STRATEGY: none
1816
1851
  script:
1817
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1852
+ - collapseable_section_start "injectvars" "Injecting variables"
1818
1853
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
1819
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1854
+ - collapseable_section_end "injectvars"
1820
1855
  - set +e
1821
1856
  - gcloud auth activate-service-account --key-file=<(echo "$CL_stage_api_GCLOUD_DEPLOY_credentialsKey")
1822
1857
  - gcloud run services delete pan-test-app-stage-api --project=asdf --region=asia-east1
@@ -1850,37 +1885,53 @@ api 🧪 test:
1850
1885
  KUBERNETES_MEMORY_REQUEST: 1Gi
1851
1886
  KUBERNETES_MEMORY_LIMIT: 4Gi
1852
1887
  script:
1853
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1888
+ - collapseable_section_start "injectvars" "Injecting variables"
1854
1889
  - export ENV_SHORT="prod"
1855
1890
  - export APP_DIR="api"
1856
1891
  - export ENV_TYPE="prod"
1857
1892
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1858
1893
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
1859
1894
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
1860
- - export HOST="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1895
+ - export HOSTNAME="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1861
1896
  - export ROOT_URL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1862
- - export HOST_INTERNAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1863
- - export HOST_CANONICAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1897
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1864
1898
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
1865
1899
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
1866
1900
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
1867
1901
  - export GCLOUD_DEPLOY_credentialsKey="$CL_prod_api_GCLOUD_DEPLOY_credentialsKey"
1868
1902
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix"
1869
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1870
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1903
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
1904
+ - collapseable_section_end "injectvars"
1905
+ - collapseable_section_start "write-dotenv-api" "write dot env for api"
1906
+ - |-
1907
+ cat <<EOF > api/.env
1908
+ ENV_SHORT=prod
1909
+ APP_DIR=api
1910
+ ENV_TYPE=prod
1911
+ HOSTNAME=$(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1912
+ ROOT_URL=$(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1913
+ HOSTNAME_INTERNAL=$(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1914
+ ROOT_URL_INTERNAL=$(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | escapeForDotEnv)
1915
+ DEPLOY_CLOUD_RUN_PROJECT_ID=asdf
1916
+ DEPLOY_CLOUD_RUN_REGION=asia-east1
1917
+ GCLOUD_DEPLOY_credentialsKey=$(printf %s "$CL_prod_api_GCLOUD_DEPLOY_credentialsKey" | escapeForDotEnv)
1918
+ GCLOUD_RUN_canonicalHostSuffix=$(printf %s "$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | escapeForDotEnv)
1919
+ _ALL_ENV_VAR_KEYS=["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
1920
+ EOF
1921
+ - collapseable_section_end "write-dotenv-api"
1871
1922
  - echo '{"id":"$(git describe --tags 2>/dev/null || git rev-parse HEAD)","time":"$CI_JOB_STARTED_AT"}' > api/__build_info.json
1872
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1923
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1873
1924
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1874
1925
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1875
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1926
+ - collapseable_section_end "nodeinstall"
1876
1927
  - cd api
1877
- - echo -e "\\e[0Ksection_start:$(date +%s):nodeinstall[collapsed=true]\\r\\e[0KEnsure node version"
1928
+ - collapseable_section_start "nodeinstall" "Ensure node version"
1878
1929
  - if [ -f ~/.nvm/nvm.sh ]; then source ~/.nvm/nvm.sh; fi
1879
1930
  - if command -v nvm &> /dev/null && [ -f ./.nvmrc ]; then nvm install; fi
1880
- - echo -e "\\e[0Ksection_end:$(date +%s):nodeinstall\\r\\e[0K"
1881
- - echo -e "\\e[0Ksection_start:$(date +%s):yarninstall[collapsed=true]\\r\\e[0KYarn install"
1931
+ - collapseable_section_end "nodeinstall"
1932
+ - collapseable_section_start "yarninstall" "Yarn install"
1882
1933
  - yarn install --immutable
1883
- - echo -e "\\e[0Ksection_end:$(date +%s):yarninstall\\r\\e[0K"
1934
+ - collapseable_section_end "yarninstall"
1884
1935
  - yarn build
1885
1936
  cache:
1886
1937
  - key: api-yarn
@@ -1891,15 +1942,13 @@ api 🧪 test:
1891
1942
  policy: pull-push
1892
1943
  paths:
1893
1944
  - api/node_modules
1894
- - key: api-next-cache
1895
- policy: pull-push
1896
- paths:
1897
- - api/.next/cache
1898
1945
  artifacts:
1899
1946
  paths:
1900
1947
  - api/__build_info.json
1901
1948
  - api/.next
1902
1949
  - api/dist
1950
+ exclude:
1951
+ - api/.env
1903
1952
  expire_in: 1 day
1904
1953
  when: always
1905
1954
  reports: {}
@@ -1925,7 +1974,7 @@ api 🧪 test:
1925
1974
  KUBERNETES_MEMORY_REQUEST: 1Gi
1926
1975
  KUBERNETES_MEMORY_LIMIT: 2Gi
1927
1976
  script:
1928
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1977
+ - collapseable_section_start "injectvars" "Injecting variables"
1929
1978
  - export APP_DIR="api"
1930
1979
  - export DOCKER_BUILD_CONTEXT="."
1931
1980
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
@@ -1941,20 +1990,20 @@ api 🧪 test:
1941
1990
  COPY --chown=node:node api/yarn.lock /app/api/yarn.lock
1942
1991
  COPY --chown=node:node .yarnrc.yml /app/.yarnrc.yml
1943
1992
  COPY --chown=node:node .yarn /app/.yarn"
1944
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
1993
+ - collapseable_section_end "injectvars"
1945
1994
  - ensureNodeDockerfile
1946
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-login[collapsed=true]\\r\\e[0KDocker Login"
1995
+ - collapseable_section_start "docker-login" "Docker Login"
1947
1996
  - gcloud auth activate-service-account --key-file=<(echo "$CL_prod_api_GCLOUD_DEPLOY_credentialsKey")
1948
1997
  - gcloud auth configure-docker asia-east1-docker.pkg.dev
1949
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-login\\r\\e[0K"
1950
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-build[collapsed=true]\\r\\e[0KDocker build"
1998
+ - collapseable_section_end "docker-login"
1999
+ - collapseable_section_start "docker-build" "Docker build"
1951
2000
  - docker build --network host --cache-from $DOCKER_CACHE_IMAGE --tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG -f $APP_DIR/Dockerfile $DOCKER_BUILD_CONTEXT --build-arg BUILDKIT_INLINE_CACHE=1
1952
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-build\\r\\e[0K"
1953
- - echo -e "\\e[0Ksection_start:$(date +%s):docker-push[collapsed=true]\\r\\e[0KDocker push and tag"
2001
+ - collapseable_section_end "docker-build"
2002
+ - collapseable_section_start "docker-push" "Docker push and tag"
1954
2003
  - docker push $DOCKER_IMAGE:$DOCKER_IMAGE_TAG
1955
2004
  - docker tag $DOCKER_IMAGE:$DOCKER_IMAGE_TAG $DOCKER_CACHE_IMAGE
1956
2005
  - docker push $DOCKER_CACHE_IMAGE
1957
- - echo -e "\\e[0Ksection_end:$(date +%s):docker-push\\r\\e[0K"
2006
+ - collapseable_section_end "docker-push"
1958
2007
  cache:
1959
2008
  - key: api-yarn
1960
2009
  policy: pull
@@ -1971,8 +2020,8 @@ api 🧪 test:
1971
2020
  image: aquasec/trivy:0.38.3
1972
2021
  variables: {}
1973
2022
  script:
1974
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
1975
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
2023
+ - collapseable_section_start "injectvars" "Injecting variables"
2024
+ - collapseable_section_end "injectvars"
1976
2025
  - trivy fs --quiet --format cyclonedx --output "__sbom.json" api
1977
2026
  artifacts:
1978
2027
  paths:
@@ -1991,35 +2040,34 @@ api 🧪 test:
1991
2040
  KUBERNETES_MEMORY_REQUEST: 200Mi
1992
2041
  KUBERNETES_MEMORY_LIMIT: 400Mi
1993
2042
  script:
1994
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
2043
+ - collapseable_section_start "injectvars" "Injecting variables"
1995
2044
  - export ENV_SHORT="prod"
1996
2045
  - export APP_DIR="api"
1997
2046
  - export ENV_TYPE="prod"
1998
2047
  - export BUILD_INFO_BUILD_ID="$(git describe --tags 2>/dev/null || git rev-parse HEAD)"
1999
2048
  - export BUILD_INFO_BUILD_TIME="$CI_JOB_STARTED_AT"
2000
2049
  - export BUILD_INFO_CURRENT_VERSION="$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")"
2001
- - export HOST="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2050
+ - export HOSTNAME="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2002
2051
  - export ROOT_URL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2003
- - export HOST_INTERNAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2004
- - export HOST_CANONICAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2052
+ - export HOSTNAME_INTERNAL="$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2005
2053
  - export ROOT_URL_INTERNAL="https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')"
2006
2054
  - export DEPLOY_CLOUD_RUN_PROJECT_ID="asdf"
2007
2055
  - export DEPLOY_CLOUD_RUN_REGION="asia-east1"
2008
2056
  - export GCLOUD_DEPLOY_credentialsKey="$CL_prod_api_GCLOUD_DEPLOY_credentialsKey"
2009
2057
  - export GCLOUD_RUN_canonicalHostSuffix="$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix"
2010
- - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOST\\",\\"ROOT_URL\\",\\"HOST_INTERNAL\\",\\"HOST_CANONICAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
2058
+ - export _ALL_ENV_VAR_KEYS="[\\"ENV_SHORT\\",\\"APP_DIR\\",\\"ENV_TYPE\\",\\"BUILD_INFO_BUILD_ID\\",\\"BUILD_INFO_BUILD_TIME\\",\\"BUILD_INFO_CURRENT_VERSION\\",\\"HOSTNAME\\",\\"ROOT_URL\\",\\"HOSTNAME_INTERNAL\\",\\"ROOT_URL_INTERNAL\\",\\"DEPLOY_CLOUD_RUN_PROJECT_ID\\",\\"DEPLOY_CLOUD_RUN_REGION\\",\\"GCLOUD_DEPLOY_credentialsKey\\",\\"GCLOUD_RUN_canonicalHostSuffix\\"]"
2011
2059
  - export DOCKER_REGISTRY="asia-east1-docker.pkg.dev"
2012
2060
  - export DOCKER_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/prod/api"
2013
2061
  - export DOCKER_CACHE_IMAGE="asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api"
2014
2062
  - export DOCKER_IMAGE_TAG="$CI_COMMIT_SHA"
2015
2063
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
2016
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
2017
- - echo -e "\\e[0Ksection_start:$(date +%s):prepare[collapsed=true]\\r\\e[0KPrepare..."
2064
+ - collapseable_section_end "injectvars"
2065
+ - collapseable_section_start "prepare" "Prepare..."
2018
2066
  - gcloud auth activate-service-account --key-file=<(echo "$CL_prod_api_GCLOUD_DEPLOY_credentialsKey")
2019
2067
  - export GCLOUD_PROJECT_NUMBER=$(gcloud projects describe asdf --format="value(projectNumber)")
2020
2068
  - 'echo "GCLOUD_PROJECT_NUMBER: $GCLOUD_PROJECT_NUMBER"'
2021
- - echo -e "\\e[0Ksection_end:$(date +%s):prepare\\r\\e[0K"
2022
- - echo -e "\\e[0Ksection_start:$(date +%s):writeenvvars[collapsed=true]\\r\\e[0KWrite env vars to file"
2069
+ - collapseable_section_end "prepare"
2070
+ - collapseable_section_start "writeenvvars" "Write env vars to file"
2023
2071
  - |
2024
2072
  cat > ____envvars.yaml <<EOF
2025
2073
  ENV_SHORT: |-
@@ -2029,40 +2077,38 @@ api 🧪 test:
2029
2077
  ENV_TYPE: |-
2030
2078
  prod
2031
2079
  BUILD_INFO_BUILD_ID: |-
2032
- $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed 's/^/ /')
2080
+ $(printf %s "$(git describe --tags 2>/dev/null || git rev-parse HEAD)" | sed '1!s/^/ /')
2033
2081
  BUILD_INFO_BUILD_TIME: |-
2034
- $(printf %s "$CI_JOB_STARTED_AT" | sed 's/^/ /')
2082
+ $(printf %s "$CI_JOB_STARTED_AT" | sed '1!s/^/ /')
2035
2083
  BUILD_INFO_CURRENT_VERSION: |-
2036
- $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed 's/^/ /')
2037
- HOST: |-
2038
- $(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
2084
+ $(printf %s "$(tag=$(git ls-remote origin "refs/tags/v*[0-9]" 2>/dev/null | cut -f 2- | sort -V | tail -1 | sed 's/refs\\/tags\\/v//'); [ -z "$tag" ] && echo "0.0.0" || echo "$tag")" | sed '1!s/^/ /')
2085
+ HOSTNAME: |-
2086
+ $(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
2039
2087
  ROOT_URL: |-
2040
- $(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
2041
- HOST_INTERNAL: |-
2042
- $(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
2043
- HOST_CANONICAL: |-
2044
- $(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
2088
+ $(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
2089
+ HOSTNAME_INTERNAL: |-
2090
+ $(printf %s "$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
2045
2091
  ROOT_URL_INTERNAL: |-
2046
- $(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed 's/^/ /')
2092
+ $(printf %s "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" | sed '1!s/^/ /')
2047
2093
  DEPLOY_CLOUD_RUN_PROJECT_ID: |-
2048
2094
  asdf
2049
2095
  DEPLOY_CLOUD_RUN_REGION: |-
2050
2096
  asia-east1
2051
2097
  GCLOUD_RUN_canonicalHostSuffix: |-
2052
- $(printf %s "$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | sed 's/^/ /')
2098
+ $(printf %s "$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | sed '1!s/^/ /')
2053
2099
  _ALL_ENV_VAR_KEYS: |-
2054
- ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOST","ROOT_URL","HOST_INTERNAL","HOST_CANONICAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
2100
+ ["ENV_SHORT","APP_DIR","ENV_TYPE","BUILD_INFO_BUILD_ID","BUILD_INFO_BUILD_TIME","BUILD_INFO_CURRENT_VERSION","HOSTNAME","ROOT_URL","HOSTNAME_INTERNAL","ROOT_URL_INTERNAL","DEPLOY_CLOUD_RUN_PROJECT_ID","DEPLOY_CLOUD_RUN_REGION","GCLOUD_DEPLOY_credentialsKey","GCLOUD_RUN_canonicalHostSuffix"]
2055
2101
 
2056
2102
  EOF
2057
- - echo -e "\\e[0Ksection_end:$(date +%s):writeenvvars\\r\\e[0K"
2058
- - echo -e "\\e[0Ksection_start:$(date +%s):deploy[collapsed=true]\\r\\e[0KDeploy to cloud run"
2103
+ - collapseable_section_end "writeenvvars"
2104
+ - collapseable_section_start "deploy" "Deploy to cloud run"
2059
2105
  - gcloud run deploy pan-test-app-prod-api --command="yarn,start" --image=asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/prod/api:$DOCKER_IMAGE_TAG --project=asdf --region=asia-east1 --labels=customer-name=pan,component-name=api,app-name=test-app,env-type=prod,env-name=prod,build-type=node,cloud-run-service-name=pan-test-app-prod-api --env-vars-file=____envvars.yaml --min-instances=0 --max-instances=100 --cpu-throttling --allow-unauthenticated --ingress=all --cpu-boost
2060
- - echo -e "\\e[0Ksection_end:$(date +%s):deploy\\r\\e[0K"
2061
- - echo -e "\\e[0Ksection_start:$(date +%s):cleanup[collapsed=true]\\r\\e[0KCleanup"
2106
+ - collapseable_section_end "deploy"
2107
+ - collapseable_section_start "cleanup" "Cleanup"
2062
2108
  - gcloud run revisions list --project=asdf --region=asia-east1 --service=pan-test-app-prod-api --limit=unlimited --sort-by=metadata.creationTimestamp --format="value(name)" --filter='(status.conditions.status=False OR status.conditions.status=Unknown)' | tail -n +6 | while read -r revisionname; do gcloud run revisions delete --project=asdf --region=asia-east1 --quiet $revisionname ; done
2063
2109
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/prod/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +7 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/prod/api@$version --quiet --delete-tags; done
2064
2110
  - gcloud artifacts docker images list asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api --sort-by=~CREATE_TIME --format="value(version)" | tail -n +2 | while read -r version; do gcloud artifacts docker images delete asia-east1-docker.pkg.dev/asdf/catladder-deploy/pan-test-app/caches/api@$version --quiet --delete-tags; done
2065
- - echo -e "\\e[0Ksection_end:$(date +%s):cleanup\\r\\e[0K"
2111
+ - collapseable_section_end "cleanup"
2066
2112
  - echo 'Uploading SBOM to Dependency Track'
2067
2113
  - /dtrackuploader https://dep.panter.swiss/ "$DT_KEY_PROD" upload "pan-test-app/api" "https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" "__sbom.json" vex.json || true
2068
2114
  - echo "CL_GITLAB_ENVIRONMENT_URL=https://$(printf %s "pan-test-app-prod-api-$CL_prod_api_GCLOUD_RUN_canonicalHostSuffix" | awk '{print tolower($0)}')" >> gitlab_environment.env
@@ -2095,9 +2141,9 @@ api 🧪 test:
2095
2141
  KUBERNETES_MEMORY_LIMIT: 400Mi
2096
2142
  GIT_STRATEGY: none
2097
2143
  script:
2098
- - echo -e "\\e[0Ksection_start:$(date +%s):injectvars[collapsed=true]\\r\\e[0KInjecting variables"
2144
+ - collapseable_section_start "injectvars" "Injecting variables"
2099
2145
  - export CLOUDSDK_CORE_DISABLE_PROMPTS="1"
2100
- - echo -e "\\e[0Ksection_end:$(date +%s):injectvars\\r\\e[0K"
2146
+ - collapseable_section_end "injectvars"
2101
2147
  - set +e
2102
2148
  - gcloud auth activate-service-account --key-file=<(echo "$CL_prod_api_GCLOUD_DEPLOY_credentialsKey")
2103
2149
  - gcloud run services delete pan-test-app-prod-api --project=asdf --region=asia-east1