ci auto deploy
This commit is contained in:
parent
58b2679492
commit
a0493bd805
|
@ -2,22 +2,23 @@ image: golang:latest
|
||||||
stages:
|
stages:
|
||||||
- build
|
- build
|
||||||
- test
|
- test
|
||||||
|
- deploy
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- mkdir -p /go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/
|
- mkdir -p "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
|
||||||
- cp -R /builds/$CI_PROJECT_PATH /go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/
|
- cp -R "/builds/$CI_PROJECT_PATH" "/go/src/dev.sum7.eu/$CI_PROJECT_NAMESPACE/"
|
||||||
- cd /go/src/dev.sum7.eu/$CI_PROJECT_PATH
|
- cd "/go/src/dev.sum7.eu/$CI_PROJECT_PATH"
|
||||||
- go get -d -t ./...
|
- go get -d -t ./...
|
||||||
|
|
||||||
build-my-project:
|
build-my-project:
|
||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- go install dev.sum7.eu/$CI_PROJECT_PATH
|
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
|
||||||
- mv /go/bin/$CI_PROJECT_NAME /builds/$CI_PROJECT_PATH
|
- mv "/go/bin/$CI_PROJECT_NAME" "/builds/$CI_PROJECT_PATH"
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- config_example.conf
|
- config_example.conf
|
||||||
- $CI_PROJECT_NAME
|
- "$CI_PROJECT_NAME"
|
||||||
|
|
||||||
test-my-project:
|
test-my-project:
|
||||||
stage: test
|
stage: test
|
||||||
|
@ -35,3 +36,15 @@ test-race-my-project:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- go test -race ./...
|
- go test -race ./...
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
only:
|
||||||
|
- master
|
||||||
|
script:
|
||||||
|
- go install "dev.sum7.eu/$CI_PROJECT_PATH"
|
||||||
|
- '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 -o StrictHostKeyChecking=no -P $SSH_PORT "/go/bin/$CI_PROJECT_NAME" "$CI_PROJECT_NAME@$SSH_HOST":/opt/$CI_PROJECT_NAME/bin
|
||||||
|
- ssh -6 -o StrictHostKeyChecking=no -p $SSH_PORT "$CI_PROJECT_NAME@$SSH_HOST" sudo /usr/bin/systemctl restart $CI_PROJECT_NAME
|
||||||
|
|
Loading…
Reference in New Issue