Skip to content

Update deploy.yml

Update deploy.yml #23

Workflow file for this run

name: build and deploy spring-api
on:
push:
branches:
- main
jobs:
build-deploy:
name: build and deploy spring-api
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v3
- name: setup jdk 18
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: 18
- name: unit tests
run: mvn -B test --file pom.xml
- name: build the app
run: |
mvn clean
mvn -B package --file pom.xml
- name: login to Docker Hub
run: echo "dckr_pat_6WT_FrLGkS3D6gOM4sVReRzaPgw" | docker login -u "battlecodes" --password-stdin
- name: build the docker image
uses: docker/build-push-action@v4
with:
context: .
dockerfile: Dockerfile
push: true
tags: battlecodes/backend-battlecodes:latest
- name: Copy files to server
run: |
scp -r -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null ./* ${{ secrets.USERNAME }}@${{ secrets.HOST }}:/root/project
- name: SSH to server and deploy
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: 22
script: |
cd /root/project
docker-compose down
docker-compose pull
docker-compose up -d