forked from decentraland/old-documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
144 lines (138 loc) Β· 4.38 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
stages:
- build
# - test
- deploy
services:
- docker:dind
# Cache modules in between jobs
cache:
# key: ${CI_COMMIT_REF_SLUG}
key: ${CI_COMMIT_REF_NAME}
paths:
- vendor/
- _site/
- .jekyll-cache
- .jekyll-metadata
deploy-preview:
stage: deploy
image: decentraland/ci-jekyll:3
variables:
SOURCE_PATH: "$CI_COMMIT_REF_NAME"
SITE_TARGET_URL: "https://docs.decentraland.io/branch/$CI_COMMIT_REF_NAME"
GITHUB_REPOSITORY: decentraland/documentation
GITHUB_SHA: $CI_COMMIT_SHA
except:
- master
before_script:
- cd .ci && npm ci
- >
npm run status -- \
--state pending \
--description "Deploying..." \
--target-url "$CI_JOB_URL"
- cd ..
after_script:
- cd .ci && npm ci
- >
if [ "$CI_JOB_STATUS" == "success" ]; then
npm run status -- \
--state success \
--description "Deployed!!!" \
--target-url "$CI_JOB_URL"
else
npm run status -- \
--state failure \
--target-url "$CI_JOB_URL"
fi
script:
# BUILD
- gem install bundler
- bundle config set path 'vendor/bundle'
- bundle install --jobs=4 --retry=3
- CI_COMMIT_REF_NAME=master
- source dcl-env
- 'echo "" > _data/environment.yml'
- 'echo "ENVIRONMENT: \"$ENVIRONMENT\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_SHA: \"$CI_COMMIT_SHA\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_SHORT_SHA: \"$CI_COMMIT_SHORT_SHA\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_REF_NAME: \"$CI_COMMIT_REF_NAME\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_BRANCH: \"$CI_COMMIT_BRANCH\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_TAG: \"$CI_COMMIT_TAG\"" >> _data/environment.yml'
- >
JEKYLL_ENV=production bundle exec jekyll build \
--incremental \
--destination "_site/branch/$SOURCE_PATH" \
--baseurl "/branch/$SOURCE_PATH"
# DEPLOY (.io)
- dcl-lock-sync
- cd .ci && npm ci && dcl-up websites-documentation
- dcl-sync-release
- PATH="$PATH:$HOME/.pulumi/bin"
- SOURCE="_site/branch/$SOURCE_PATH"
- TARGET="s3://$(pulumi stack output bucketName)/branch/$SOURCE_PATH"
- EXPIRES="$(date --date='7 day' '+%Y-%m-%dT00:00:00Z')"
- echo "aws s3 sync $SOURCE $TARGET --expires $EXPIRES"
- cd .. && aws s3 sync $SOURCE $TARGET --expires $EXPIRES --acl public-read
- cd .ci && dcl-cache-invalidation
- >
npm run status -- \
--state success \
--name "live" \
--description "Site is live!" \
--target-url "$SITE_TARGET_URL"
deploy:
stage: deploy
image: decentraland/ci-jekyll:3
variables:
GITHUB_REPOSITORY: decentraland/documentation
GITHUB_SHA: $CI_COMMIT_SHA
only:
- master
before_script:
- cd .ci && npm ci
- >
npm run status -- \
--state pending \
--description "Deploying..." \
--target-url "$CI_JOB_URL"
- cd ..
after_script:
- cd .ci && npm ci
- >
if [ "$CI_JOB_STATUS" == "success" ]; then
npm run status -- \
--state success \
--description "Deployed!!!" \
--target-url "$CI_JOB_URL"
else
npm run status -- \
--state failure \
--target-url "$CI_JOB_URL"
fi
script:
# BUILD
- gem install bundler
- bundle config set path 'vendor/bundle'
- bundle install --jobs=4 --retry=3
- CI_COMMIT_REF_NAME=release
- source dcl-env
- 'echo "" > _data/environment.yml'
- 'echo "ENVIRONMENT: \"$ENVIRONMENT\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_SHA: \"$CI_COMMIT_SHA\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_SHORT_SHA: \"$CI_COMMIT_SHORT_SHA\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_REF_NAME: \"$CI_COMMIT_REF_NAME\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_BRANCH: \"$CI_COMMIT_BRANCH\"" >> _data/environment.yml'
- 'echo "CI_COMMIT_TAG: \"$CI_COMMIT_TAG\"" >> _data/environment.yml'
- JEKYLL_ENV=production bundle exec jekyll build --incremental --destination _site
# DEPLOY (.org)
- dcl-lock-sync
- cd .ci && npm install && dcl-up websites-documentation
- dcl-sync-release && cd ..
- dcl-upload _site
- cd .ci && dcl-cache-invalidation
- >
npm run status -- \
--state success \
--name "live" \
--description "Site is live!" \
--target-url "https://docs.decentraland.org/"