-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
66 lines (59 loc) · 1.47 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
image: node:latest
stages:
- react-build
- server-deploy
- react-deploy
variables:
POSTGRES_DB: frd010-example
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: postgres
before_script:
- npm install -g yarn
react-build:
stage: react-build
before_script:
- pwd
- cd front-end/my-app
only:
- production
script:
- yarn install
- yarn build
artifacts:
paths:
- front-end/my-app/build
server-deploy:
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' > private.pem
- chmod 400 private.pem
- ssh-add private.pem > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H ${SERVER_HOSTNAME} > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
stage: server-deploy
only:
- production
script:
- ssh ubuntu@${SERVER_HOSTNAME}
"cd project3-nest-cafe/back-end;
git pull origin master;
yarn install;
yarn knex migrate:latest --env production;
forever restart index.js;"
react-deploy:
image: "python:3.6"
stage: react-deploy
before_script:
- pip install awscli
dependencies:
- react-build
only:
- production
script:
- pwd
- aws s3 sync front-end/my-app/build s3://${BUCKET_NAME} --delete
- aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION} --paths "/*"