Added gitci

Signed-off-by: Marcin Woźniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-12-08 18:26:35 +01:00
parent acf80cc78d
commit d85cdb9b22
Signed by: y0rune
GPG Key ID: F204C385F57EB348
1 changed files with 40 additions and 0 deletions

40
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,40 @@
stages:
- build
- deploy
build:
stage: build
image: java:14
script:
- echo "Start building App"
- rm -rf restservice/src/main/resources/application.properties
- echo "spring.profiles.active=prod" > restservice/src/main/resources/application.properties
- mvn clean
- mvn install
- cd restservice
- mvn clean package spring-boot:repackage
- echo "Build successfully!"
artifacts:
expire_in: 1 hour
paths:
- restservice/target/
deploy_production:
stage: deploy
before_script:
- apt-get update
- apt-get --yes --force-yes install rsync
script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- echo "Deploying to server"
- ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl stop plannaplan-backend"
- rsync --progress target/*.jar --delete backend@wmi-backend-gc.plannaplan.pl:/opt/plannaplan-backend/backend.jar
- sleep 5
- ssh backend@wmi-backend-gc.plannaplan.pl -t "sudo systemctl start plannaplan-backend"
- echo "Deployed"
#only:
#- master