Merge pull request #123 from solid-connection/main #22
This file contains 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: Build Gradle and Deploy | ||
on: | ||
push: | ||
branches: [ "release" ] | ||
workflow_dispatch: | ||
jobs: | ||
build-gradle: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
- name: Set secret files | ||
token: ${{ secrets.SUBMODULE_ACCESS_TOKEN }} | ||
submodules: true | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies. | ||
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
- name: Grant execute permission for Gradle wrapper(gradlew) | ||
run: chmod +x ./gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew bootJar -Dspring.profiles.active=prod | ||
- name: Copy jar file to remote | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
source: "./build/libs/*.jar" | ||
target: "/home/${{ secrets.USERNAME }}/solid-connect-server/" | ||
- name: Copy docker file to remote | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
source: "./Dockerfile" | ||
target: "/home/${{ secrets.USERNAME }}/solid-connect-server/" | ||
- name: Copy docker compose file to remote | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
source: "./docker-compose.yml" | ||
target: "/home/${{ secrets.USERNAME }}/solid-connect-server/" | ||
- name: Run docker compose | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script_stop: true | ||
script: | | ||
cd /home/${{ secrets.USERNAME }}/solid-connect-server | ||
docker compose down | ||
docker compose up -d --build |