-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
65 lines (55 loc) · 1.27 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
image: golang:latest
services:
- postgres:13-alpine
variables:
REPO_NAME: gitlab.com/ranfdev/discepto
POSTGRES_DB: discepto
POSTGRES_PASSWORD: discepto
POSTGRES_USER: discepto
POSTGRES_HOST_AUTH_METHOD: trust
.go-cache:
variables:
GOPATH: $CI_PROJECT_DIR/.go
before_script:
- mkdir -p .go
cache:
paths:
- .go/pkg/mod/
stages:
- test
- build
- staging
test:
stage: test
extends: .go-cache
script:
- make test
build:
stage: build
needs:
- test
extends: .go-cache
script:
- make pack
artifacts:
paths:
- ./build/discepto.tar.gz
deploy-to-staging:
needs:
- build
image: alpine
stage: staging
environment:
name: "staging"
script: |
apk add openssh-client
eval $(ssh-agent -s)
##
## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
## We're using tr to fix line endings which makes ed25519 keys work
## without extra base64 encoding.
## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
##
echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
alias sshp="ssh -o StrictHostKeyChecking=no"
< ./build/discepto.tar.gz sshp "gitlab@$STAGING_SERVER_DOMAIN" "tar -xzf - && systemctl --user restart discepto.service"