-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
67 lines (63 loc) · 1.64 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
67
---
stages:
- test
- build
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
Tests:
stage: test
image: golang:1.14
tags:
- docker
script:
- echo -e "machine gitlab.private.com\nlogin gitlab-ci-token\npassword ${CI_JOB_TOKEN}" > ~/.netrc
- go mod vendor
- go test ./pkg/...
- go run cmd/slack_cmd_test/*.go --config cmd/slack_cmd_test/unkatan.yml
cache:
key: global_cache
paths:
- vendor/
Container building:
stage: build
image: docker:19.03.14-git
services:
- name: docker:19.03.14-dind
alias: docker
tags:
- docker
only:
- tags
variables:
IMAGE_TAG: ${CI_COMMIT_REF_SLUG}
before_script:
- docker login ${CI_REGISTRY} -u gitlab-ci-token -p ${CI_JOB_TOKEN}
script:
- docker build --force-rm --build-arg VER=${CI_COMMIT_REF_SLUG} --build-arg PRIVATE_USER=gitlab-ci-token --build-arg PRIVATE_PASSWORD=${CI_JOB_TOKEN} --tag ${CI_REGISTRY_IMAGE}:${IMAGE_TAG} .
- docker push ${CI_REGISTRY_IMAGE}:${IMAGE_TAG}
cache:
key: global_cache
paths:
- vendor/
Deploy:
stage: deploy
image: ssh:20.04
tags:
- docker
only:
- tags
allow_failure: false
when: manual
environment:
name: production
url: http://slackbot1b.private.com/unkatan/
resource_group: production
script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- ssh gitlab-runner@${DEPLOY_HOST} -- unkatan $CI_COMMIT_REF_SLUG $DOCKER_USER $DOCKER_PASS < <(env | grep '^APP_' | sed -e 's/^APP_//')