Skip to content

Merge pull request #24 from MarvinBo44/Frontend/api_fix #15

Merge pull request #24 from MarvinBo44/Frontend/api_fix

Merge pull request #24 from MarvinBo44/Frontend/api_fix #15

Workflow file for this run

name: "Deploy App"
on:
push:
branches:
- main
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: Build Frontend
working-directory: frontend
run: |
npm install --legacy-peer-deps
npm run build
- uses: actions/upload-artifact@v3
with:
name: frontend-build
path: frontend/dist/
build-backend:
runs-on: ubuntu-latest
needs: build-frontend
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: frontend-build
path: backend/src/main/resources/static
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
cache: 'maven'
- name: Build with maven
run: mvn -B package --file backend/pom.xml
- uses: actions/upload-artifact@v3
with:
name: app.jar
#Change app.jar to your applications finalname.jar
path: backend/target/app.jar
push-to-docker-hub:
runs-on: ubuntu-latest
needs: build-backend
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: app.jar
path: backend/target
- name: Login to DockerHub
uses: docker/login-action@v1
with:
#Set dockerhub username
username: marvmarv44
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v2
with:
push: true
#Set dockerhub project (replace "accesscoder/testdeploy")
tags: marvmarv44/to_be_able:latest
context: .
deploy:
runs-on: ubuntu-latest
needs: push-to-docker-hub
steps:
- name: Restart docker container
uses: appleboy/ssh-action@master
with:
host: capstone-project.de
#Set App Name (replace "example" with your ssh user name)
username: bo-java-23-2-weather
password: ${{ secrets.SSH_PASSWORD }}
#Set App Name (replace "bo-java-23-2-pokemon" with your ssh user name)
#Set dockerhub project (replace "accesscoder/testdeploy")
#Set IP (replace "10.0.7.11" with your ip address)
script: |
sudo docker stop bo-java-23-2-weather
sudo docker rm bo-java-23-2-weather
sudo docker run --pull=always --name bo-java-23-2-weather --network capstones --ip 10.0.7.12 --detach --env MONGO_DB_URI=${{ secrets.MONGO_DB_URI }} marvmarv44/to_be_able:latest
sleep 15s
sudo docker logs bo-java-23-2-weather
- name: Check the deployed service URL
uses: jtalk/url-health-check-action@v3
with:
#Set App Name (replace "bo-java-23-2-pokemon" with your ssh user name)
url: http://bo-java-23-2-weather.capstone-project.de
max-attempts: 3
retry-delay: 5s
retry-all: true