Update README.md #50
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: "Deploy App on NF" | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v2 | |
with: | |
node-version: '18' | |
- name: Build Frontend | |
run: | | |
cd frontend | |
npm install | |
npm run build | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: frontend-build | |
path: frontend/dist/ | |
build-backend: | |
runs-on: ubuntu-latest | |
needs: build-frontend | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK | |
uses: actions/setup-java@v2 | |
with: | |
#Set Java Version | |
java-version: '20' | |
distribution: 'adopt' | |
cache: 'maven' | |
- uses: actions/download-artifact@v2 | |
with: | |
name: frontend-build | |
path: backend/src/main/resources/static | |
- name: Build with maven | |
run: mvn -B package --file backend/pom.xml | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: app.jar | |
path: backend/target/netrunner.jar | |
push-to-docker-hub: | |
runs-on: ubuntu-latest | |
needs: build-backend | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/download-artifact@v2 | |
with: | |
name: app.jar | |
path: backend/target | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
#Set dockerhub username | |
username: toshymoshy | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
#Set dockerhub username/projectName | |
tags: toshymoshy/netrunner | |
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 "alpha"-"tango") | |
username: cgn-java-23-2-anton | |
password: ${{ secrets.SSH_PASSWORD_NF }} | |
#Set App Name (replace "example" with "alpha"-"tango") | |
#Set dockerhub project (replace "bartfastiel/java-capstone-project.de-example-app") | |
#Set IP (replace "10.0.1.99" with "10.0.1.1"-"10.0.1.20") | |
script: | | |
sudo docker stop cgn-java-23-2-anton | |
sudo docker rm cgn-java-23-2-anton | |
sudo docker run --pull=always --name cgn-java-23-2-anton --network capstones --ip 10.0.5.3 --restart always --detach --env MONGO_DB_URI="${{ secrets.MONGO_DB_URI }}" --env MAPBOX_ACCESS_TOKEN="${{ secrets.MAPBOX_ACCESS_TOKEN }}" --env GOOGLE_API_KEY="${{ secrets.GOOGLE_API_KEY }}" toshymoshy/netrunner:latest | |
sleep 15s | |
sudo docker logs cgn-java-23-2-anton | |
- name: Check the deployed service URL | |
uses: jtalk/url-health-check-action@v3 | |
with: | |
#Set App Name (replace "example" with "alpha"-"tango") | |
url: http://cgn-java-23-2-anton.capstone-project.de | |
max-attempts: 3 | |
retry-delay: 5s | |
retry-all: true |