From 42eab09b2713952fa95d3afd84c93ae3fcb99a0b Mon Sep 17 00:00:00 2001 From: kaya <33685994+gayeon1025@users.noreply.github.com> Date: Mon, 15 Apr 2024 13:31:24 +0900 Subject: [PATCH] Create deployment_scp.yml --- .github/workflows/deployment_scp.yml | 76 ++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/deployment_scp.yml diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml new file mode 100644 index 0000000..57de88f --- /dev/null +++ b/.github/workflows/deployment_scp.yml @@ -0,0 +1,76 @@ +# This workflow uses actions that are not certified by GitHub. +# They are provided by a third-party and are governed by +# separate terms of service, privacy policy, and support +# documentation. +# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle + +name: Deployment + +on: + workflow_dispatch: + push: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Set up JDK 21 + uses: actions/setup-java@v4 + with: + java-version: '21' + distribution: 'temurin' + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: build + - uses: actions/upload-artifact@v3 + with: + name: jar + path: build/libs + + send-jar: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download jar + uses: actions/download-artifact@v3 + with: + name: jar + - name: Send jar to remote server + uses: appleboy/scp-action@master + with: + host: 34.47.80.179 + username: kaya.realcoding + source: "devlog_springboot-0.0.1-SNAPSHOT.jar" + target: "/home/kaya.realcoding" + key: ${{ secrets.PRIVATE_KEY }} + + run-app: + needs: send-jar + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Move deploy.sh + uses: appleboy/scp-action@master + with: + host: 34.47.80.179 + username: kaya.realcoding + source: "deploy.sh" + target: "/home/kaya.realcoding" + key: ${{ secrets.PRIVATE_KEY }} + - name: Execute script + uses: appleboy/ssh-action@master + with: + username: kaya.realcoding + host: 34.47.80.179 + key: ${{ secrets.PRIVATE_KEY }} + script_stop: true + script: cd /home/kaya.realcoding && chmod +x deploy.sh && ./deploy.sh