From 6925b48ac618cbebaeaaf06b0a940b4473a16320 Mon Sep 17 00:00:00 2001 From: hanueleee Date: Sun, 31 Dec 2023 23:13:12 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20cicd=20=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cicd-be.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/cicd-be.yml diff --git a/.github/workflows/cicd-be.yml b/.github/workflows/cicd-be.yml new file mode 100644 index 00000000..7d6173f7 --- /dev/null +++ b/.github/workflows/cicd-be.yml @@ -0,0 +1,51 @@ +name: Backend CI/CD + +on: + pull_request: + branches: [ develop ] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Check out Repository + uses: actions/checkout@v3 + + - name: Set up JDK11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew clean build + + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: cicdsample + path: build/libs/*.jar + + deploy: + needs: build + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: cicdsample + + - name: Setup SSH + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: SCP transfer + run: scp *.jar ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }}:~/cicd + + - name: Execute remote shell script + run: | + ssh ${{ secrets.SSH_USER }}@${{ secrets.SERVER_IP }} "./deploy.sh"