-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
59 lines (40 loc) · 1.5 KB
/
.gitlab-ci.yml
File metadata and controls
59 lines (40 loc) · 1.5 KB
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
image:
name: node:18
variables:
APP_NAME: jba4213-react
PROJECT_NAME: client-4 #Change this when the project changes (e.g. client-3 etc): To your output web folder
OUTPUT_DIR: public/$PROJECT_NAME
.script-create-dir: &script-create-dir |
if [ -d "$OUTPUT_DIR" ]; then
# Control will enter here if $DIRECTORY exists.
echo $OUTPUT_DIR "found, no need to create"
else
echo $OUTPUT_DIR "not found, creating ..."
mkdir $OUTPUT_DIR
ls -lFa $OUTPUT_DIR
fi
cache:
paths:
- node_modules/
before_script:
- *script-create-dir #This has to run before you change paths
- cd $APP_NAME #Go to your sub-directory path, so yarn and npm work
- pwd
- npm install
- node --version
pages:
stage: deploy
script:
# This magical incantation will inject a build version just before </body>"
# Float left on div to place at bottom with react components
- sed -i "s|</body>|<div style="float:left"><small>Built on GitLab branch <code>$CI_COMMIT_REF_NAME</code> commit <code>$CI_COMMIT_SHORT_SHA</code> $(date)</small></div></body>|g" public/index.html
- npm run build # Do a production build to build/ folder
# - rm -rf public # React public/ shouldn't conflict with GitLab public/
# - mv build public # Move to the directory GitLab pages expects
- rm -rf ../$OUTPUT_DIR # Remove the old files
- mv build ../$OUTPUT_DIR
- ls -lFa ../$OUTPUT_DIR #After the npm deploy
- echo "Your web page will be at /"$PROJECT_NAME
artifacts:
paths:
- public