2021-10-02 18:00:35 +00:00
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: testing
|
|
|
|
|
|
|
|
steps:
|
2021-10-26 23:20:26 +00:00
|
|
|
- name: unittests
|
2021-10-26 21:08:07 +00:00
|
|
|
image: golang:1.17-buster
|
2021-10-02 18:00:35 +00:00
|
|
|
environment:
|
|
|
|
SNAPSHOTS_S3_ENDPOINT: minio:9000
|
|
|
|
TEST_S3_ENDPOINT: minio:9000
|
|
|
|
commands:
|
|
|
|
- go mod tidy
|
|
|
|
- make test
|
|
|
|
|
|
|
|
services:
|
|
|
|
- name: minio
|
|
|
|
image: minio/minio:latest
|
|
|
|
environment:
|
|
|
|
MINIO_ROOT_USER: test
|
|
|
|
MINIO_ROOT_PASSWORD: testtest
|
|
|
|
command:
|
|
|
|
- server
|
|
|
|
- /data
|
|
|
|
- --console-address
|
|
|
|
- :9001
|
2021-10-26 21:08:07 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
2021-10-28 23:03:17 +00:00
|
|
|
name: Dev deploy
|
2021-10-26 21:08:07 +00:00
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: build
|
2021-10-26 22:01:01 +00:00
|
|
|
# image: golang:1.17-buster # this one is used in production
|
2021-10-28 23:03:17 +00:00
|
|
|
image: golang:1.17-bullseye # this one is used in dev
|
2021-10-26 21:08:07 +00:00
|
|
|
commands:
|
|
|
|
- go mod tidy
|
|
|
|
- make build
|
2021-10-26 21:13:20 +00:00
|
|
|
|
2021-10-26 21:08:07 +00:00
|
|
|
- name: deploy
|
|
|
|
image: debian:buster
|
|
|
|
environment:
|
2021-10-26 22:08:29 +00:00
|
|
|
#NODE: node-x.rosti.cz
|
2021-10-26 23:20:26 +00:00
|
|
|
NODES: 192.168.1.236
|
2021-10-26 21:08:07 +00:00
|
|
|
SSH_KEY:
|
2021-10-26 21:13:20 +00:00
|
|
|
from_secret: SSH_KEY
|
2021-10-26 21:08:07 +00:00
|
|
|
commands:
|
|
|
|
- apt update && apt install -y ssh
|
2021-10-26 23:20:26 +00:00
|
|
|
- |
|
|
|
|
for NODE in $NODES; do
|
|
|
|
echo "\033[0;32mDeploying $NODE\033[0m"
|
|
|
|
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
|
|
|
echo "\033[1;33m.. scanning SSH keys\033[0m"
|
|
|
|
ssh-keyscan $NODE > ~/.ssh/known_hosts
|
|
|
|
echo "\033[1;33m.. copying the binary\033[0m"
|
|
|
|
scp node-api root@$NODE:/usr/local/bin/node-api_
|
|
|
|
echo "\033[1;33m.. replacing the binary\033[0m"
|
|
|
|
ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
|
2021-10-26 23:26:04 +00:00
|
|
|
echo "\033[1;33m.. restarting service\033[0m"
|
2021-10-26 23:20:26 +00:00
|
|
|
ssh root@$NODE systemctl restart node-api
|
|
|
|
done
|
2021-10-26 21:08:07 +00:00
|
|
|
|
|
|
|
trigger:
|
|
|
|
branch:
|
|
|
|
- main
|
|
|
|
event:
|
|
|
|
- push
|
|
|
|
- custom
|
2021-10-26 21:13:20 +00:00
|
|
|
|
|
|
|
depends_on:
|
2021-10-26 21:14:34 +00:00
|
|
|
- testing
|
2021-10-26 23:11:57 +00:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
kind: pipeline
|
|
|
|
type: docker
|
|
|
|
name: Production deploy
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: build
|
|
|
|
image: golang:1.17-buster # this one is used in production
|
2021-10-28 23:03:17 +00:00
|
|
|
#image: golang:1.17-bullseye # this one is used in dev
|
2021-10-26 23:11:57 +00:00
|
|
|
commands:
|
|
|
|
- go mod tidy
|
|
|
|
- make build
|
|
|
|
|
|
|
|
- name: deploy
|
|
|
|
image: debian:buster
|
|
|
|
environment:
|
2021-10-26 23:23:39 +00:00
|
|
|
NODES: node-18.rosti.cz 83.167.243.34
|
2021-10-26 23:11:57 +00:00
|
|
|
SSH_KEY:
|
|
|
|
from_secret: SSH_KEY
|
|
|
|
commands:
|
|
|
|
- apt update && apt install -y ssh
|
|
|
|
- |
|
|
|
|
for NODE in $NODES; do
|
|
|
|
echo "\033[0;32mDeploying $NODE\033[0m"
|
2021-10-26 23:20:26 +00:00
|
|
|
mkdir -p ~/.ssh && echo "$SSH_KEY" > ~/.ssh/id_ed25519 && chmod 600 ~/.ssh/id_ed25519
|
|
|
|
echo "\033[1;33m.. scanning SSH keys\033[0m"
|
2021-10-26 23:11:57 +00:00
|
|
|
ssh-keyscan $NODE > ~/.ssh/known_hosts
|
2021-10-26 23:20:26 +00:00
|
|
|
echo "\033[1;33m.. copying the binary\033[0m"
|
2021-10-26 23:11:57 +00:00
|
|
|
scp node-api root@$NODE:/usr/local/bin/node-api_
|
2021-10-26 23:20:26 +00:00
|
|
|
echo "\033[1;33m.. replacing the binary\033[0m"
|
2021-10-26 23:11:57 +00:00
|
|
|
ssh root@$NODE mv /usr/local/bin/node-api_ /usr/local/bin/node-api
|
2021-10-26 23:26:04 +00:00
|
|
|
echo "\033[1;33m.. restarting service\033[0m"
|
2021-10-26 23:11:57 +00:00
|
|
|
ssh root@$NODE systemctl restart node-api
|
|
|
|
done
|
|
|
|
|
|
|
|
depends_on:
|
|
|
|
- testing
|
|
|
|
|
|
|
|
trigger:
|
|
|
|
event:
|
|
|
|
- promote
|
|
|
|
target:
|
|
|
|
- production
|