Add deploy job and deploy script
This commit is contained in:
parent
e8f481a493
commit
ce2202bc41
|
@ -1,5 +1,6 @@
|
||||||
stages:
|
stages:
|
||||||
- test-lint-format
|
- test-lint-format
|
||||||
|
- deploy
|
||||||
|
|
||||||
.job_setup:
|
.job_setup:
|
||||||
image: python:3.9
|
image: python:3.9
|
||||||
|
@ -30,3 +31,18 @@ pytest:
|
||||||
artifacts:
|
artifacts:
|
||||||
reports:
|
reports:
|
||||||
cobertura: coverage.xml
|
cobertura: coverage.xml
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
stage: deploy
|
||||||
|
only:
|
||||||
|
- develop
|
||||||
|
before_script:
|
||||||
|
# https://docs.gitlab.com/ee/ci/ssh_keys/#ssh-keys-when-using-the-docker-executor
|
||||||
|
- "command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )"
|
||||||
|
- eval $(ssh-agent -s)
|
||||||
|
- echo "${VPS_DEPLOYMENT_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
|
||||||
|
- mkdir -p ~/.ssh
|
||||||
|
- chmod 700 ~/.ssh
|
||||||
|
script:
|
||||||
|
- echo "Deploying ${CI_COMMIT_BRANCH}:${CI_COMMIT_SHA} ..."
|
||||||
|
- ssh musicube@${VPS_HOST} -o StrictHostKeyChecking=no -p ${VPS_SSH_PORT} "cd musicube; ./deploy.sh $CI_COMMIT_BRANCH"
|
||||||
|
|
8
Makefile
8
Makefile
|
@ -1,9 +1,13 @@
|
||||||
|
include docker.env
|
||||||
|
export $(shell sed 's/=.*//' docker.env)
|
||||||
|
|
||||||
|
SHELL = /bin/bash
|
||||||
GIT_COMMIT != git log --pretty=format:'%h' -n 1
|
GIT_COMMIT != git log --pretty=format:'%h' -n 1
|
||||||
|
|
||||||
|
|
||||||
build:
|
build:
|
||||||
source <(cat docker.env | sed -e 's/^/export /g')
|
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN} \
|
--build-arg DISCORD_BOT_TOKEN=${DISCORD_BOT_TOKEN} \
|
||||||
--build-arg YOUTUBE_COOKIES=${YOUTUBE_COOKIES} \
|
--build-arg YOUTUBE_COOKIES=${YOUTUBE_COOKIES} \
|
||||||
--build-arg GIT_COMMIT=${GIT_COMMIT} \
|
--build-arg GIT_COMMIT=${GIT_COMMIT} \
|
||||||
-t musicube:${GIT_COMMIT} -t musicube:latest \
|
-t musicube:${GIT_COMMIT} -t musicube:latest \
|
||||||
|
|
|
@ -42,6 +42,13 @@ Requirements:
|
||||||
```
|
```
|
||||||
$ docker --version
|
$ docker --version
|
||||||
Docker version 20.10.8, build 3967b7d28e
|
Docker version 20.10.8, build 3967b7d28e
|
||||||
|
$ make --version
|
||||||
|
GNU Make 4.3
|
||||||
|
Built for x86_64-pc-linux-gnu
|
||||||
|
Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
||||||
|
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
|
||||||
|
This is free software: you are free to change and redistribute it.
|
||||||
|
There is NO WARRANTY, to the extent permitted by law.
|
||||||
```
|
```
|
||||||
|
|
||||||
Build image:
|
Build image:
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BRANCH="$1"
|
||||||
|
|
||||||
|
# Exit immediately if a command fails
|
||||||
|
set -e
|
||||||
|
# Log every command
|
||||||
|
set -x
|
||||||
|
|
||||||
|
git status
|
||||||
|
git fetch
|
||||||
|
git checkout "$BRANCH"
|
||||||
|
git pull --ff-only
|
||||||
|
make build
|
||||||
|
docker stop musicube || true
|
||||||
|
docker run --rm --detach --name musicube musicube
|
Loading…
Reference in New Issue