-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
83 lines (75 loc) · 1.79 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
# pull in node 10 docker image
image: node:10.15.0
stages:
- test
- build
- deploy
.cache_template: &cache_definition # put node_modules and .cache to cache
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- coverage/
# test stage, run unit tests and linting
test:
before_script:
- yarn
<<: *cache_definition
script:
- yarn format
- yarn test
stage: test
# sonar qube code quality job
sonarqube:
<<: *cache_definition
stage: test
script:
- yarn eslint-sonarqube
- yarn sonar-scanner -Dsonar.login=$SONAR_LOGIN
only:
- development
- main
# build stage, node_modules are downloaded from cache
build:
<<: *cache_definition
stage: build
script: yarn build
# create artifacts from the public directory
artifacts:
paths:
- public/
.deploy_template:
stage: deploy
image: python:latest
# scripts to be run on deployment
script:
- pip install awscli
- aws s3 sync ./public/ s3://$TARGET_BUCKET_NAME/ --delete --exclude="*node_modules/*" --include "*"
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION --paths "/*"
# use artifacts from build stage
dependencies:
- build
deploy_development:
extends: .deploy_template
variables:
TARGET_BUCKET_NAME: 'zds-dev'
AWS_REGION: 'eu-central-1'
CLOUDFRONT_DISTRIBUTION: 'ET351YZOMAVPH'
environment:
name: development
url: https://dev-zds.zepdev.net
only:
- development
deploy_production:
extends: .deploy_template
variables:
TARGET_BUCKET_NAME: 'zds-live'
AWS_REGION: 'eu-central-1'
CLOUDFRONT_DISTRIBUTION: 'E3N62GDZMDUN0M'
environment:
name: production
url: https://live-zds.zepdev.net
# only trigger deployment into production manually
when: manual
only:
- main