Frontend/.drone.yml

80 lines
2.4 KiB
YAML
Raw Normal View History

2021-08-09 22:05:19 -04:00
---
global-variables:
2021-08-10 20:43:55 -04:00
release: &release ${DRONE_BRANCH##**/}
2021-08-09 22:05:19 -04:00
environment: &environment
CRE_REGISTRY_IMAGE: registry.fyloz.dev:5443/colorrecipesexplorer/frontend
CRE_PORT: 9102
CRE_RELEASE: *release
alpine-image: &alpine-image alpine:latest
docker-registry-repo: &docker-registry-repo registry.fyloz.dev:5443/colorrecipesexplorer/frontend
kind: pipeline
name: default
type: docker
steps:
- name: set-docker-tags-latest
image: *alpine-image
environment:
<<: *environment
commands:
- echo -n "latest" > .tags
when:
branch: develop
- name: set-docker-tags-release
image: *alpine-image
environment:
<<: *environment
commands:
- echo -n "latest-release,$CRE_RELEASE" > .tags
when:
branch: release/**
2021-08-10 20:43:55 -04:00
- name: containerize
2021-08-09 22:05:19 -04:00
image: plugins/docker
environment:
<<: *environment
settings:
repo: *docker-registry-repo
when:
branch:
- develop
- release/**
- name: deploy
image: alpine:latest
environment:
<<: *environment
CRE_REGISTRY_IMAGE: *docker-registry-repo
DEPLOY_SERVER:
from_secret: deploy_server
DEPLOY_SERVER_USERNAME:
from_secret: deploy_server_username
DEPLOY_SERVER_SSH_PORT:
from_secret: deploy_server_ssh_port
DEPLOY_SERVER_SSH_KEY:
from_secret: deploy_server_ssh_key
2021-08-10 20:43:55 -04:00
DEPLOY_CONTAINER_NAME: cre_frontend
2021-08-09 22:05:19 -04:00
commands:
- apk update
- apk add --no-cache openssh-client
- mkdir -p ~/.ssh
- echo "$DEPLOY_SERVER_SSH_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 700 ~/.ssh/id_rsa
- eval $(ssh-agent -s)
- ssh-add ~/.ssh/id_rsa
- ssh-keyscan -p $DEPLOY_SERVER_SSH_PORT -H $DEPLOY_SERVER >> ~/.ssh/known_hosts
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker stop $DEPLOY_CONTAINER_NAME || true && docker rm $DEPLOY_CONTAINER_NAME || true"
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker pull $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
- ssh -p $DEPLOY_SERVER_SSH_PORT $DEPLOY_SERVER_USERNAME@$DEPLOY_SERVER "docker run -d -p $CRE_PORT:80 --name=$DEPLOY_CONTAINER_NAME $CRE_REGISTRY_IMAGE:$CRE_RELEASE"
when:
branch: release/**
2021-08-10 20:43:55 -04:00
2021-08-09 22:05:19 -04:00
trigger:
branch:
- develop
2021-08-10 20:43:55 -04:00
- release/**
2021-08-09 22:05:19 -04:00
- master