ci auto deploy

This commit is contained in:
Martin/Geno 2019-02-28 15:16:30 +01:00
parent 58b2679492
commit 2a420e843c
No known key found for this signature in database
GPG Key ID: 9D7D3C6BFF600C6A
1 changed files with 12 additions and 0 deletions

View File

@ -2,6 +2,7 @@ image: golang:latest
stages:
- build
- test
- deploy
before_script:
- mkdir -p /go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/
@ -35,3 +36,14 @@ test-race-my-project:
stage: test
script:
- go test -race ./...
deploy:
stage: deploy
only:
- master
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' | ssh-add - > /dev/null
- scp -6 -P $SSH_PORT /builds/$CI_PROJECT_PATH "$CI_PROJECT_NAME@$SSH_HOST":/opt/$CI_PROJECT_NAME/bin
- ssh -6 -p $SSH_PORT "$CI_PROJECT_NAME@$SSH_HOST" sudo /usr/bin/systemctl restart $CI_PROJECT_NAME