А Вы разве находитесь в местах, не столь отдаленных, что Вас интересует мнение Федеральной Службы Исполнения Наказаний? :D
image: golang:latest
before_script:
- apt-get update -qq && apt-get install -y -qq sshpass
- go get github.com/gorilla/mux
- go get github.com/gorilla/websocket
- '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
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- mkdir -p /go/src/gitlab.com/$GROUP_NAME
- git clone git@gitlab.com:$GROUP_NAME/$REPOSITORY_NAME.git /go/src/gitlab.com/$GROUP_NAME/$REPOSITORY_NAME
- mkdir -p $CI_PROJECT_DIR/build/
- cp -r $CI_PROJECT_DIR/src/public $CI_PROJECT_DIR/build
stages:
- build
compile:
stage: build
script:
- cd /go/src/gitlab.com/$GROUP_NAME/$REPOSITORY_NAME/src
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR/build/main
- cd $CI_PROJECT_DIR/build
- sshpass -V
- export SSHPASS=$USER_PASS
- sshpass -e ssh -o stricthostkeychecking=no $USER@$HOST systemctl stop $SERVICE_NAME
- sshpass -e scp -o stricthostkeychecking=no -r . $USER@$HOST:$TARGET_DIR_ON_HOST
- sshpass -e ssh -o stricthostkeychecking=no $USER@$HOST systemctl restart $SERVICE_NAME
artifacts:
paths:
- main
image: golang:latest
variables:
REPO_NAME: $REPO_NAME
before_script:
- go get github.com/gorilla/mux
- go get github.com/gorilla/websocket
- '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
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
- ls
- cd src
- mkdir -p /go/src/gitlab.com/Undermove
- git clone git@gitlab.com:Undermove/RockScissorPaperWebInterface.git /go/src/gitlab.com/Undermove/RockScissorPaperWebInterface
- cd /go/src/gitlab.com/Undermove/RockScissorPaperWebInterface
stages:
- build
compile:
stage: build
script:
- cd /go/src/gitlab.com/Undermove/RockScissorPaperWebInterface/src
- go build -race -ldflags "-extldflags '-static'" -o $CI_PROJECT_DIR
- systemctl restart rpsonline
artifacts:
paths:
- mybinary
ssh-rsa {здесь сам ключ} user@host