Update README.md #6
This file contains hidden or 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 to Server | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew bootJar -x test | |
- name: Rename JAR to app.jar | |
run: mv build/libs/*.jar build/libs/app.jar | |
- name: Upload JAR to Raspberry Pi | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.PI_HOST }} | |
username: ${{ secrets.PI_USERNAME }} | |
password: ${{ secrets.PI_PASSWORD }} | |
port: ${{ secrets.PI_PORT }} | |
source: "build/libs/app.jar" | |
target: "Project/homework" | |
strip_components: 2 | |
- name: Restart Docker Compose on Raspberry Pi | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.PI_HOST }} | |
username: ${{ secrets.PI_USERNAME }} | |
password: ${{ secrets.PI_PASSWORD }} | |
port: ${{ secrets.PI_PORT }} | |
script: | | |
cd Project/homework | |
docker-compose up -d --build --force-recreate |