-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
101 lines (91 loc) · 2.2 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
image: node:alpine
cache:
key: "$CI_COMMIT_REF_NAME"
untracked: true
paths:
- node_modules/
variables:
NODE_ENV: "production"
NPM_CONFIG_LEVEL: "warn"
stages:
- lint
- build
- test
- security
- staging
check_lint:
tags:
- node
stage: lint
script:
- npm install -g eslint
- eslint .
building:
tags:
- node
stage: build
before_script:
- apk add --no-cache --virtual git
- apk --no-cache add --virtual builds-deps build-base python # required for alpine based images to build bcrypt. (see https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#alpine-linux-based-images)
script:
- npm install
- npm rebuild bcrypt --build-from-source # rebuild bcrypt for alpine based images. (see https://github.com/kelektiv/node.bcrypt.js/wiki/Installation-Instructions#alpine-linux-based-images)
allow_failure: false
package-scan:
tags:
- node
stage: test
before_script:
- npm install -g npm-check
script:
- npm-check --skip-unused --production
allow_failure: true
snyk-security-scan:
tags:
- node
stage: security
before_script:
- npm install -g snyk && snyk auth $SNYK_TOKEN
script:
- snyk test
allow_failure: true
nsp-security-scan:
tags:
- node
stage: security
before_script:
- npm install -g nsp
script:
- nsp test
allow_failure: true
retire-security-scan:
tags:
- node
stage: security
before_script:
- npm install -g retire
script:
- retire
allow_failure: true
deploy_staging:
tags:
- node
stage: staging
before_script:
- apk add --no-cache --virtual git
- apk add --no-cache --virtual openssh
- mkdir -p ~/.ssh
- echo "$DOKKU_SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan -H "dokku.${DOKKU_DOMAIN}" >> ~/.ssh/known_hosts
- git config --global user.email "$GITLAB_USER_EMAIL"
- git config --global user.name "$GITLAB_USER_ID"
script:
- echo "Pushing to Dokku..."
- git push --force ssh://dokku@dokku.${DOKKU_DOMAIN}/${DOKKU_APP} HEAD:refs/heads/master
- echo "Pushed to Dokku."
environment:
name: staging
url: https://${DOKKU_APP}.${DOKKU_DOMAIN}
only:
- tags