[DEPLOY] v2.2.0 #16
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: "[PROD] Build Gradle and Deploy" | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| workflow_dispatch: | |
| jobs: | |
| build-gradle: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout the code | |
| uses: actions/checkout@v4 | |
| with: | |
| 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 | |
| - 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.prod.yml" | |
| target: "/home/${{ secrets.USERNAME }}/solid-connect-server/" | |
| - name: Copy alloy config file to remote | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.PRIVATE_KEY }} | |
| source: "./docs/infra-config/config.alloy" | |
| target: "/home/${{ secrets.USERNAME }}/solid-connect-server/" | |
| - name: Copy nginx config to remote | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.PRIVATE_KEY }} | |
| source: "./docs/infra-config/nginx.prod.conf" | |
| target: "/home/${{ secrets.USERNAME }}/solid-connection-prod/nginx" | |
| rename: "default.conf" | |
| - name: Run docker compose and apply nginx config | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.HOST }} | |
| username: ${{ secrets.USERNAME }} | |
| key: ${{ secrets.PRIVATE_KEY }} | |
| script_stop: true | |
| script: | | |
| sudo cp /home/${{ secrets.USERNAME }}/solid-connection-prod/nginx/default.conf /etc/nginx/conf.d/default.conf | |
| sudo nginx -t | |
| sudo nginx -s reload | |
| cd /home/${{ secrets.USERNAME }}/solid-connect-server | |
| docker compose -f docker-compose.prod.yml down | |
| docker compose -f docker-compose.prod.yml up -d --build |