Merge pull request #158 from chalIengers/MinkeySon-patch-3 #81
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Deploy to Ubuntu Server | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 16 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '16' | |
distribution: 'temurin' | |
- name: Prepare application.properties | |
run: | | |
mkdir config | |
echo "${{ secrets.APP_PROPERTIES }}" > config/application.properties | |
- name: Build with Maven | |
run: | | |
mvn clean | |
mvn package | |
- name: web docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_REPO }} -p ${{ secrets.DOCKER_KEY }} | |
docker build -t ${{ secrets.DOCKER_REPO }}/challengers-backend:latest . | |
docker push ${{ secrets.DOCKER_REPO }}/challengers-backend | |
- name: Deploy to Ubuntu Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.SSH_PRIVATE_KEY }} | |
port : 1030 | |
script: | | |
docker stop challengers-backend | |
docker rm challengers-backend | |
docker pull ${{ secrets.DOCKER_REPO }}/challengers-backend:latest | |
docker run -d -p 8080:8080 --net challengers --name challengers-backend ${{ secrets.DOCKER_REPO }}/challengers-backend:latest |