forked from cjhappTNG/ciCdPlayground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
87 lines (80 loc) · 1.82 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
stages:
- build
- test
- deploy
variables:
ROLE_ARN: arn:aws:iam::530798195059:role/tng-curriculum-cicd-playground-deployment-test-role-gitlab
Build:
stage: build
image: node:lts-alpine
script:
- yarn install --frozen-lockfile
- yarn build
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
paths:
- public/build
- node_modules
- ~/.cache/Cypress
Test:
stage: test
image: node:lts-alpine
script:
- yarn test
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- public/build
- node_modules
artifacts:
when: always
reports:
junit:
- public/junit.xml
IntegrationTest:
stage: test
image: cypress/base:18.14.1
script:
- yarn install --frozen-lockfile
- yarn build
- yarn test:e2e
artifacts:
when: always
paths:
- cypress/videos/**/*.mp4
- cypress/screenshots/**/*.png
expire_in: 1 day
Provision:
stage: deploy
before_script:
- echo "${CI_JOB_JWT_V2}" > /tmp/web_identity_token
variables:
AWS_WEB_IDENTITY_TOKEN_FILE: /tmp/web_identity_token
AWS_ROLE_ARN: ${ROLE_ARN}
AWS_REGION: eu-central-1
image: node:lts-alpine
script:
- cd infrastructure/
- yarn install --frozen-lockfile
- yarn cdk deploy --verbose --require-approval never --context instanceName=${CI_COMMIT_REF_NAME}
Deploy:
stage: deploy
before_script:
- echo "${CI_JOB_JWT_V2}" > /tmp/web_identity_token
variables:
AWS_WEB_IDENTITY_TOKEN_FILE: /tmp/web_identity_token
AWS_ROLE_ARN: ${ROLE_ARN}
AWS_REGION: eu-central-1
image:
name: amazon/aws-cli:latest
entrypoint:
- ""
cache:
key: "$CI_COMMIT_REF_NAME"
policy: pull
paths:
- public/build
script:
- aws s3 cp ./public s3://cicd-workshop-playground-${CI_COMMIT_REF_NAME} --recursive