Files
Discord-Twitch-Live-Notifier/.gitlab-ci.yml

80 lines
2.0 KiB
YAML

stages:
- lint
- build
- deploy
.install-deps-script: &install-deps
- curl -sSL https://install.python-poetry.org | python -
- export PATH=$PATH:$HOME/.local/bin
- poetry --version
- poetry install
.base:
image: python:3.11.2
.lint:
extends: .base
stage: lint
before_script:
- *install-deps
######################################
# #
# LINT STEPS #
# #
######################################
black:
extends: .lint
script:
- poetry run black . --check --verbose --diff
isort:
extends: .lint
script:
- poetry run isort --check .
######################################
# #
# BUILD STEPS #
# #
######################################
build:
stage: build
image: docker:23.0.1
services:
- name: docker:23.0.1-dind
alias: docker
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker build -f Dockerfile -t $IMAGE_TAG --build-arg version=$CI_COMMIT_SHA .
- docker push $IMAGE_TAG
######################################
# #
# DEPLOY STEPS #
# #
######################################
deploy:
stage: deploy
image: alpine:latest
before_script:
- 'command -v ssh-agent >/dev/null || ( apk add --update openssh )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan $REMOTE_HOST >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- ssh $SSH_USER@$REMOTE_HOST "bash -c 'cd /home/raphael/twitch-notifier && ./start.sh'"
only:
- main