diff --git a/.github/workflows/java.yml b/.github/workflows/java.yml new file mode 100644 index 0000000..c92db65 --- /dev/null +++ b/.github/workflows/java.yml @@ -0,0 +1,48 @@ +name: Java Deployment + +on: + push: + branches: + - 'master' + - 'development' + pull_request: + branches: + - 'master' + - 'development' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up JDK 21 maven + uses: actions/setup-java@v2 + with: + java-version: 21 + + - name: Build with Maven + run: mvn -B clean package --file pom.xml + + deploy: + runs-on: ubuntu-latest + needs: [ build ] + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + + steps: + - name: Execute SSH Commands + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST }} + username: root + key: ${{ secrets.SSH_PRIVATE_KEY }} + port: 22 + script_stop: true + script: | + cd /srv/tts-game/TTS-API + eval $(keychain --eval ../.ssh/api-key) + git pull origin master + service tts-api restart \ No newline at end of file