-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
77 lines (70 loc) · 1.66 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
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
stages:
- lint
- test
- dev
.build:
image: node:18.7.0
script:
- mv $env .env
- yarn install
- yarn build
artifacts:
paths:
- build
.deploy:
image: python:3.10
before_script:
- pip install awscli
eslint:
stage: lint
image: node:18.7.0
before_script:
- yarn install
script:
- node_modules/eslint/bin/eslint.js
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
sonarqube-check:
stage: test
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
rules:
- if: '$CI_PIPELINE_SOURCE=="merge_request_event"'
build-dev:
extends: .build
stage: dev
environment:
name: dev
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_REF_NAME == "main"'
deploy-dev:
extends: .deploy
stage: dev
environment:
name: dev
needs:
- job: build-dev
script:
- aws s3 cp ./build/ s3://$S3_BUCKET/ --recursive --include "*"
- aws cloudfront create-invalidation --distribution-id $(aws cloudfront list-distributions --query "DistributionList.Items[*].{id:Id,origin:Origins.Items[0].Id}[?origin=='${S3_BUCKET}.s3.${AWS_DEFAULT_REGION}.amazonaws.com'].id" --output text) --paths "/*"
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: '$CI_COMMIT_REF_NAME == "main"'