UNPKG

1.81 kBYAMLView Raw
1# Use the docker runner
2image: node:8
3
4before_script:
5# Install yarn
6# ref: https://yarnpkg.com/zh-Hans/docs/install#linux-tab
7# - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
8# - echo "deb http://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
9# - apt-get update -y
10# - apt-get install yarn -y
11# install ssh-agent
12# ref: https://docs.gitlab.com/ee/ci/ssh_keys/README.html
13- 'which ssh-agent || ( apt-get install openssh-client -y )'
14# run ssh-agent
15- eval $(ssh-agent -s)
16# add ssh key stored in SSH_PRIVATE_KEY variable to the agent store
17# - ssh-add <(echo "$SSH_PRIVATE_KEY")
18# disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks)
19# WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config
20- mkdir -p ~/.ssh
21- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
22- pwd
23- which nodejs
24- nodejs -v
25- which npm
26- npm -v
27- which yarn
28- yarn --version
29- yarn config set cache-folder .yarn
30
31cache:
32 key: "$CI_BUILD_REF_NAME"
33 paths:
34 - node_modules/
35 - .yarn/
36
37# jobs sequense pipeline
38stages:
39- test
40- build
41- deploy
42
43# test job: lint, test project
44test:
45 tags:
46 - node-8
47 script:
48 - yarn install
49 - npm run lint
50 - npm run test
51 stage: test
52
53# build job: build project and upload artifacts for deploy
54build:
55 # It would upload artifacts to gitlab and next stage for deploy
56 artifacts:
57 name: "${CI_BUILD_REF_NAME}_${CI_BUILD_REF}"
58 expire_in: 1 day
59 paths:
60 - _public/
61 tags:
62 - node-8
63 script:
64 - yarn install
65 - npm run build
66 stage: build
67
68# deploy job
69deploy:
70 tags:
71 - node-8
72 script:
73 - yarn install
74 # You should add deploy script here
75 environment:
76 name: demo
77 url: http://demo.25sprout
78 stage: deploy
79 only:
80 - master