-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
59 lines (52 loc) · 1.23 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
default:
interruptible: false
image: node:18-alpine
cache:
policy: pull-push
when: on_success
key:
files:
- yarn.lock
paths:
- node_modules/
- .yarn
before_script:
- yarn config set cache-folder .yarn
- yarn install --frozen-lockfile --no-progress
stages:
- build
- test
- deploy
build-job:
stage: build
script:
- yarn run build
test-job:
stage: test
script:
- yarn run test
lint-job:
stage: test
script:
- yarn run lint
deploy-job:
stage: deploy
environment: production
only:
- main
before_script: # Setup SSH
- 'command -v ssh-agent >/dev/null || (apk update && apk add --no-progress openssh)'
## Give the right permissions, otherwise ssh-add will refuse to add files.
- chmod 400 "$SSH_PRIVATE_KEY"
- eval $(ssh-agent -s)
- ssh-add "$SSH_PRIVATE_KEY"
## Create the SSH directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- cp "$SSH_KNOWN_HOSTS" ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- echo "Deploying application..."
- scp deploy.sh $SSH_USER@$SSH_HOST:/app
- ssh $SSH_USER@$SSH_HOST "/app/deploy.sh"
- echo "Application successfully deployed."