This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
166 lines (158 loc) · 3.84 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
stages:
- build
- test
- deploy
- publish
variables:
APP_NAME: "patternlab-standard"
REVIEW_BUCKET: "patternlab-standard-static-review"
PROD_BUCKET: "patternlab-standard-static-prod"
START_URL: "public/index.html?p=templates-homepage"
GITLAB_PAGES_URL: "https://patternlab.gitlab.io/PatternLabStandard"
PROD_URL: "https://static.example.com"
bundle:
image: "node:alpine"
stage: build
script:
- npm ci
- npm run bundle
cache:
paths:
- public
- dist
- patternlab
- node_modules
policy: push
only:
refs:
- tags
- merge_requests
- master
changes:
- src/**/*
testing:
stage: test
script:
- npm run test
cache:
paths:
- node_modules
policy: pull
only:
refs:
- merge_requests
- master
changes:
- src/**/*
deploy_review_s3:
image: "infrastructureascode/aws-cli"
stage: deploy
variables:
GIT_STRATEGY: none
AWS_ACCESS_KEY_ID: $REVIEW_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $REVIEW_AWS_SECRET_ACCESS_KEY
cache:
paths:
- public
- dist
- patternlab
policy: pull
script:
- aws s3 sync --delete dist/ s3://$REVIEW_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/dist/ --cache-control "no-cache" --only-show-errors
- aws s3 sync --delete patternlab/ s3://$REVIEW_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/patternlab/ --cache-control "no-cache" --only-show-errors
- aws s3 sync --delete public/ s3://$REVIEW_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/public/ --cache-control "no-cache" --only-show-errors
environment:
name: Review/$CI_COMMIT_REF_NAME
url: https://s3.amazonaws.com/$REVIEW_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/$START_URL
on_stop: stop_review_s3
only:
refs:
- merge_requests
- master
changes:
- src/**/*
stop_review_s3:
image: "infrastructureascode/aws-cli"
stage: deploy
cache: {}
variables:
GIT_STRATEGY: none
AWS_ACCESS_KEY_ID: $REVIEW_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $REVIEW_AWS_SECRET_ACCESS_KEY
script:
- aws s3 rm s3://$REVIEW_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME --recursive --only-show-errors
when: manual
environment:
name: Review/$CI_COMMIT_REF_NAME
action: stop
only:
refs:
- merge_requests
changes:
- src/**/*
except:
- master
- tags
pages:
stage: deploy
variables:
GIT_STRATEGY: none
cache:
paths:
- public
- dist
- patternlab
policy: pull
script:
- mv public web
- mkdir public
- mv patternlab dist public/
- mv web public/public
artifacts:
paths:
- public
environment:
name: GiLab Pages master
url: $GITLAB_PAGES_URL/$START_URL
only:
refs:
- master
changes:
- src/**/*
release:
image: "aplyca/semantic-release"
stage: deploy
cache: {}
script:
- semantic-release
when: manual
only:
refs:
- master
changes:
- src/**/*
publish_s3:
image: "infrastructureascode/aws-cli"
stage: publish
variables:
GIT_STRATEGY: none
AWS_ACCESS_KEY_ID: $PROD_AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY: $PROD_AWS_SECRET_ACCESS_KEY
cache:
paths:
- public
- dist
- patternlab
policy: pull
script:
- aws s3 sync --delete dist/ s3://$PROD_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/dist/ --cache-control "max-age=31557600" --only-show-errors
- aws s3 sync --delete patternlab/ s3://$PROD_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/patternlab/ --cache-control "max-age=31557600" --only-show-errors
- aws s3 sync --delete public/ s3://$PROD_BUCKET/$APP_NAME/$CI_COMMIT_REF_NAME/public/ --cache-control "no-cache" --only-show-errors
environment:
name: Release/$CI_COMMIT_REF_NAME
url: $PROD_URL/$APP_NAME/$CI_COMMIT_REF_NAME/$START_URL
only:
refs:
- tags
variables:
- $CI_COMMIT_REF_NAME =~ /^[0-9]+\.[0-9]+\.[0-9]+$/