Skip to content

Commit

Permalink
[BE] chore : ci/cd 파일 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
320Hwany committed Apr 11, 2024
1 parent 99d2fa3 commit b679b48
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/backend-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Backend Build with Gradle

on:
push:
branches: [ "backend-main" ]
pull_request:
branches: [ "main", "backend-main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Cache Gradle dependencies
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('backend/**/*.gradle*', 'backend/**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Create Config
run: |
mkdir -p src/main/resources
mkdir -p src/test/resources
echo "${{ secrets.MAIN_APPLICATION_YML }}" > src/main/resources/application.yml
echo "${{ secrets.MAIN_APPLICATION_DEV_YML }}" > src/main/resources/application-dev.yml
echo "${{ secrets.MAIN_APPLICATION_PROD_YML }}" > src/main/resources/application-prod.yml
echo "${{ secrets.TEST_APPLICATION_YML }}" > src/test/resources/application.yml
echo "${{ secrets.TEST_APPLICATION_TEST_YML }}" > src/test/resources/application-test.yml
working-directory: backend

- name: Grant execute permission for Gradle
run: chmod +x gradlew
working-directory: backend

- name: Build with Gradle
run: ./gradlew build
working-directory: backend

- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Add SSH key to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.BE_SERVER_IP }} >> ~/.ssh/known_hosts

- name: SCP transfer
run: scp backend/build/libs/*.jar ${{ secrets.SSH_USER }}@${{ secrets.BE_SERVER_IP }}:~/deploy
24 changes: 24 additions & 0 deletions .github/workflows/backend-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Deploy Backend Application

on:
workflow_dispatch:

permissions:
contents: read

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Add SSH key to known hosts
run: |
mkdir -p ~/.ssh
ssh-keyscan ${{ secrets.BE_SERVER_IP }} >> ~/.ssh/known_hosts
- name: Deploy Backend application
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.BE_SERVER_IP }} "bash /home/ubuntu/deploy/deploy.sh"

0 comments on commit b679b48

Please sign in to comment.