forked from gopal1409/radisysgitlab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
77 lines (71 loc) · 1.73 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
image: node
stages:
- build
- test
- deploy
- deployment test
- deploy staging
- deploy production
- production test
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
variables:
STAGING_DOMAIN: demonic-hospital-staging.surge.sh
PRODUCTION_DOMAIN: demonic-hospital.surge.sh
build website:
stage: build
script:
- echo $CI_COMMIT_SHORT_SHA
- npm install
- npm install -g gatsby-cli
- gatsby build
- sed -i "s/%%VERSION%%/$CI_COMMIT_SHORT_SHA/" ./public/index.html
artifacts:
paths:
- ./public
test artifact:
image: alpine
stage: test
when: manual
script:
- grep -q "Gatsby" ./public/index.html
test website:
stage: test
when: manual
script:
- npm install
- npm install -g gatsby-cli
- gatsby serve &
- sleep 3
- curl "http://localhost:9000" | grep -q "Gatsby"
deploy to staging:
stage: deploy staging
environment:
name: staging
url: http://$STAGING_DOMAIN
only:
- main
script:
- npm install --global surge
- surge --project ./public --domain $STAGING_DOMAIN
deploy to production:
stage: deploy production
environment:
name: production
url: $PRODUCTION_DOMAIN
only:
- main
script:
- npm install --global surge
- surge --project ./public --domain $PRODUCTION_DOMAIN
production tests:
image: alpine
stage: production test
only:
- main
script:
- apk add --no-cache curl
- curl -s "http://$PRODUCTION_DOMAIN" | grep -q "Welcome to"
- curl -s "http://$PRODUCTION_DOMAIN" | grep -q "$CI_COMMIT_SHORT_SHA"