This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
/
.gitlab-ci.yml
125 lines (114 loc) · 2.14 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
image: node:16
stages:
- caching
- lint check
- build
- deploy review
- deploy staging
- test staging
- pages
variables:
STAGING_DOMAIN: amfoss_in-staging.surge.sh
caching:
stage: caching
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ./node_modules
policy: push
script:
- npm install
- echo ${CI_COMMIT_REF_SLUG}
lint-check:
stage: lint check
only:
- merge_requests
before_script:
- npm install prettier
script:
- npm run lint-check
build-website:
stage: build
only:
- master
- merge_requests
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- ./node_modules
before_script:
- npm install next
script:
- echo ${CI_COMMIT_REF_SLUG}
- npm install
- npm run export
- rm -rf public
- mv out public
artifacts:
paths:
- ./public
# A BaseDeploy
.deploy template: &deploy
environment:
url: http://$DOMAIN
before_script:
- npm install -g surge
script:
- surge --project ./public --domain $DOMAIN
deploy review:
<<: *deploy
stage: deploy review
only:
- merge_requests
variables:
DOMAIN: amfoss-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA.surge.sh
environment:
name: review/$CI_COMMIT_REF_NAME.surge.sh
on_stop: stop review
stop review:
stage: deploy review
only:
- merge_requests
variables:
GIT_STRATEGY: none
when: manual
environment:
name: review/$CI_COMMIT_REF_NAME.surge.sh
action: stop
script:
- npm install -g surge
- surge teardown amfoss-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA.surge.sh
deploy staging:
<<: *deploy
except:
- schedules
stage: deploy staging
# Only triggers on master branch changes
only:
- master
- cicd
variables:
DOMAIN: $STAGING_DOMAIN
environment:
name: staging
test staging:
except:
- schedules
image: alpine
stage: test staging
only:
- master
- cicd
script:
- apk add --no-cache curl grep
- curl -s http://$STAGING_DOMAIN
- echo "Commit SHA:" "$CI_COMMIT_SHORT_SHA"
pages:
stage: pages
script:
- echo " Deploying Pages"
artifacts:
paths:
- public
only:
- master