This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
.drone.yml
57 lines (48 loc) · 1.56 KB
/
.drone.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
kind: pipeline
type: docker
name: application
steps:
- name: staging-deployment
image: docker:git
volumes:
- name: dockersock
path: /var/run/docker.sock
environment:
DOCKER_REGISTRY_USER:
from_secret: DOCKER_REGISTRY_USER
DOCKER_REGISTRY_PASSWORD:
from_secret: DOCKER_REGISTRY_PASSWORD
SERVER_ADDRESS:
from_secret: SERVER_ADDRESS
SSH_PRIVATE_KEY:
from_secret: SSH_PRIVATE_KEY
SSH_KNOWN_HOSTS:
from_secret: SSH_KNOWN_HOSTS
SERVER_USER:
from_secret: SERVER_USER
commands:
- sleep 5 # just to let docker to be ready
- echo "Configuring the ssh"
## Install ssh-agent if not already installed, it's required by docker.
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
## Run ssh-agent inside the docker container
- eval "$(ssh-agent -s)"
## Add the ssh private key variable to the agent store.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - >/dev/null
## Create the ssh directory and give it the right permissions
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
## Configuring the ssh known hosts and gibe it the right permissions
- echo "$SSH_KNOWN_HOSTS" >~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- cd server && bin/build.sh && bin/deploy.sh
trigger:
branch:
- master
event:
- push
volumes:
- name: dockersock
host:
path: /var/run/docker.sock