forked from S-ResearchStack/web-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
66 lines (60 loc) · 1.55 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
image: node:16.15-alpine
# job rules cannot access variables which are not declared globally
# so we need to define defaults here and then redefine in workflow rules
variables:
IS_MERGE_REQUEST: '0'
IS_MAIN_BRANCH: '0'
IS_SCHEDULE: '0'
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
IS_MERGE_REQUEST: '1'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
IS_MAIN_BRANCH: '1'
- if: $CI_PIPELINE_SOURCE == "schedule"
variables:
IS_SCHEDULE: '1'
default:
before_script:
- corepack enable
test:
stage: test
script:
- yarn install --immutable
- yarn format:check
- yarn lint
- yarn build
cache:
key:
files:
- yarn.lock
paths:
- node_modules/
- .yarn
rules:
- if: $IS_MAIN_BRANCH == "1"
bump_version:
stage: deploy
variables:
GIT_STRATEGY: clone
GIT_DEPTH: ''
script:
- apk add --no-cache git
- git config --global user.email "[email protected]"
- git config --global user.name "Gitlab CI"
- git checkout -b ${CI_COMMIT_BRANCH}
- yarn plugin import version
- yarn version patch
- git add package.json
- VERSION=$(echo "console.log(require('./package.json').version)" | node)
- git commit -m "version ${VERSION}"
- git push https://${CI_REGISTRY_USER}:${API_TOKEN}@${CI_REPOSITORY_URL#*@} ${CI_COMMIT_BRANCH} -o ci.skip
rules:
- if: $IS_MAIN_BRANCH == "1"
check_vulnerabilities:
script:
- yarn npm audit
rules:
- if: $IS_SCHEDULE == "1"