Skip to content

Commit

Permalink
�deploy: 배포 워크플로우 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SproutMJ authored May 26, 2024
1 parent 09022b3 commit 21b86bb
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/ci.cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
name: ci/cd

on:
workflow_dispatch:

permissions:
contents: read

jobs:
build-backend:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: backend

steps:
- name: Set up Repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: "17"
distribution: "corretto"

- name: Give permission for Gradle
run: chmod +x gradlew

- name: Cache Gradle
id: cache-gradle
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew bootJar

- name: Upload jar file artifact
uses: actions/upload-artifact@v4
with:
name: BackendApplicationJar
path: backend/build/libs/*.jar

build-frontend:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: frontend

steps:
- name: Set up Repository
uses: actions/checkout@v4

- name: Setup node with cache
uses: actions/setup-node@v4
with:
node-version: 20
cache: "npm"
cache-dependency-path: "**/package-lock.json"

- name: Install dependencies
run: npm install

- name: Build App
run: npm run build

- name: Upload frontend build file to artifact
uses: actions/upload-artifact@v4
with:
name: FrontendApplication
path: frontend/out

deploy:
needs: [build-backend, build-frontend]
runs-on: self-hosted

steps:
- name: Remove previous version FRONT app
working-directory: frontend/prod/
run: rm -rf dist

- name: Download FRONT build file from artifact
uses: actions/download-artifact@v4
with:
name: FrontendApplication
path: frontend/prod/

- name: Remove previous version BACK jar
working-directory: backend/prod/
run: rm -f *.jar

- name: Download BACK jar file from artifact
uses: actions/download-artifact@v4
with:
name: BackendApplicationJar
path: backend/prod/

- name: Deploy BACK to production server
working-directory: backend/prod/
run: ./start.sh

0 comments on commit 21b86bb

Please sign in to comment.