diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1f51e5e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + branches: + - stable + +env: + FOLDER: /home/pi/api/ + +jobs: + build: + name: Build and release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'adopt' + + - name: Build + run: mvn clean package + + - 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_IP }} >> ~/.ssh/known_hosts + + - name: SSH Commands + run: | + scp -P 2222 target/api-1.0.0-jar-with-dependencies.jar ${{ secrets.SSH_DESTINATION }}:"$FOLDER" + ssh -C -p 2222 ${{ secrets.SSH_DESTINATION }} "screen -XS API quit && cd $FOLDER && ./start.sh" \ No newline at end of file