Update build_and_deploy.yml

This commit is contained in:
Filip Koňařík
2023-09-27 10:20:47 +02:00
committed by GitHub
parent 6c9dbc754c
commit 76eba8575e

View File

@@ -4,11 +4,33 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
build: build:
uses: ./.github/workflows/build.yml runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java JDK
uses: actions/setup-java@v3.13.0
with:
distribution: 'temurin'
java-version: '20'
- name: Build project
run: ./mvnw install
deploy: deploy:
needs: build needs: build
uses: ./.github/workflows/deploy.yml runs-on: ubuntu-latest
secrets: environment:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} name: oauth-playground.online
SSH_HOST: ${{ secrets.SSH_HOST }} url: https://sso.oauth-playground.online
SSH_USER: ${{ secrets.SSH_USER }} steps:
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Stop service
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "systemctl stop OAuthServer"
- name: Deploy with rsync
run: rsync -avz /home/runner/work/oauth-playground-server/oauth-playground-server/target/oauth-playground-server-1.0.0-SNAPSHOT-runner.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/var/oauth-online-server
- name: Start service
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "systemctl start OAuthServer"