-
Notifications
You must be signed in to change notification settings - Fork 23
/
.gitlab-ci.yml
103 lines (95 loc) · 3.18 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
stages:
- build
- deploy
.stage_image_cache_beforeScript_artifacts_webapp: &stage_image_cache_beforeScript_artifacts_webapp
stage: build
image: node:12
cache:
paths:
- node_modules/
- .yarn
before_script:
- yarn install
artifacts:
paths:
- packages/ganttlab-adapter-webapp/dist
webapp:gtm:
<<: *stage_image_cache_beforeScript_artifacts_webapp
script:
- export VUE_APP_GTM_CONTAINER_ID="${GTM_CONTAINER_ID}"
- yarn run build:webapp
only:
- master
webapp:
<<: *stage_image_cache_beforeScript_artifacts_webapp
script:
- yarn run build:webapp
sonarcloud:
stage: build
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
.stage_image_dependencies_script_only_aws: &stage_image_dependencies_script_only_aws
stage: deploy
image:
name: amazon/aws-cli
entrypoint: ["/bin/bash", "-l", "-c"]
dependencies:
- webapp:gtm
script:
- THE_S3_BUCKET="${THE_STACK_NAME}"
# create/update the deployment CloudFormation stack
- aws cloudformation deploy --stack-name ${THE_STACK_NAME} --template-file devops/deploy/AWS/CloudFormation/stack.yaml --tags billing-project=${BILLING_PROJECT} --parameter-overrides DomainName=${DOMAIN_NAME} ZoneName=${ZONE_NAME}
- aws cloudformation update-termination-protection --enable-termination-protection --stack-name ${THE_STACK_NAME}
# sync (with deletion) the built website from the artifacts of former pipeline stage right into the S3 bucket
- aws s3 sync packages/ganttlab-adapter-webapp/dist/ "s3://${THE_S3_BUCKET}" --delete
# invalidate /index.html from CloudFront for users to get the latest version straight away
- CLOUDFRONT_DISTRIBUTION_ID=$(aws cloudformation describe-stack-resource --stack-name ${THE_STACK_NAME} --logical-resource-id CloudFrontDistribution | grep PhysicalResourceId | cut -d \" -f4)
- aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION_ID} --paths /index.html
only:
- master
AWS-dot-org:
<<: *stage_image_dependencies_script_only_aws
variables:
THE_STACK_NAME: "app-dot-ganttlab-dot-org-production"
BILLING_PROJECT: "app-dot-ganttlab-dot-org"
DOMAIN_NAME: "app.ganttlab.org"
ZONE_NAME: "ganttlab.org"
environment:
name: app.ganttlab.org
url: https://app.ganttlab.org/
AWS-dot-com:
<<: *stage_image_dependencies_script_only_aws
variables:
THE_STACK_NAME: "app-dot-ganttlab-dot-com-production"
BILLING_PROJECT: "app-dot-ganttlab-dot-com"
DOMAIN_NAME: "app.ganttlab.com"
ZONE_NAME: "ganttlab.com"
environment:
name: app.ganttlab.com
url: https://app.ganttlab.com/
DockerHub:
stage: deploy
image: docker:git
dependencies:
- webapp
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
script:
- docker info
- docker login -u "${DOCKER_HUB_USER}" -p "${DOCKER_HUB_PASSWORD}" docker.io
- docker build -f devops/deploy/DockerHub/Dockerfile -t "ganttlab/ganttlab:latest" .
- docker push index.docker.io/ganttlab/ganttlab:latest
only:
- master