This repository has been archived by the owner on Jul 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.gitlab-ci.yml
94 lines (85 loc) · 1.88 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
# Build - Build necessary JS files
# Test - Run tests
# Deploy - Deploy application to static web/docker images/npm registry
stages:
- build
- test
- deploy
# Configuration
variables:
AWS_ACCESS_KEY_ID: "" # Example for access key
CONTAINER_IMAGE: 36node/react-app-sketch:$CI_BUILD_TAG
CONTAINER_RELEASE_IMAGE: 36node/react-app-sketch:latest
CI_BRANCH: ci/building_$CI_BUILD_ID
DEPLOY_PATH: root@yourmachine:/path/to/app
cache:
paths:
- node_modules/
- dist/
key: ${CI_BUILD_REF_NAME}
untracked: true
# Job: Build
# Build dist
build:
stage: build
before_script:
- echo "building branch:$CI_BUILD_REF_NAME tag:$CI_BUILD_TAG"
script:
- cnpm install
- NODE_ENV=production npm run build
artifacts:
paths:
- dist/
# Job: Bump
# Bump version
bump:
stage: build
before_script:
- export CI_PUSH_REPO=`echo $CI_BUILD_REPO | perl -pe 's#.*@(.+?(\:\d+)?)/#git@\1:#'`
- git config user.name "CI Builder"
- git config user.email "[email protected]"
- git remote set-url --push origin ${CI_PUSH_REPO}
script:
- git checkout -b $CI_BRANCH
- npm version patch -m "[CI SKIP] Bump version to %s by CI"
- git push origin ${CI_BRANCH}:${CI_BUILD_REF_NAME}
after_script:
- git checkout master
- git branch -D $CI_BRANCH
only:
- master
# Job: Test
# Run tests against our application
# If this fails, we do not deploy
test:
stage: test
script:
- npm run lint
- npm run test
only:
- branches
- tags
# Job: release docker-image
docker-image:
stage: deploy
script:
- docker build -t $CONTAINER_IMAGE .
- docker tag $CONTAINER_IMAGE $CONTAINER_RELEASE_IMAGE
only:
- tags
# Job: Deploy web
web:
stage: deploy
script:
- npm run deploy -- ${DEPLOY_PATH}
only:
- master
- tags
# Job: npm bpulish
publish:
stage: deploy
script:
- cnpm publish
only:
- tags
- master