name: Build & Deploy on: workflow_dispatch: jobs: build-and-deploy: runs-on: ubuntu-latest environment: name: oauth-playground.online url: https://sso.oauth-playground.online 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 - 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 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"