Skip to content

Commit

Permalink
Merge pull request #61 from kookmin-sw/backend/feat/#58
Browse files Browse the repository at this point in the history
✨ CI/CD 설정
  • Loading branch information
J-Yong99 authored Apr 6, 2024
2 parents e9b7de3 + 5dd3d1b commit ec0ec87
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 26 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Deploy

on:
push:
branches:
- deploy/v1

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: 17 # 원하는 Java 버전으로 변경
distribution: 'temurin'

- uses: actions/checkout@v3

- run: touch ./backend/moment/moment-server/auth/src/main/resources/application.properties
- run: echo "${{ secrets.AUTH_PROPERTIES }}" > ./backend/moment/moment-server/auth/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/core/src/main/resources/application.properties
- run: echo "${{ secrets.CORE_PROPERTIES }}" > ./backend/moment/moment-server/core/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/mail/src/main/resources/application.properties
- run: echo "${{ secrets.MAIL_PROPERTIES }}" > ./backend/moment/moment-server/mail/src/main/resources/application.properties

- run: touch ./backend/moment/moment-server/scheduler/src/main/resources/application.properties
- run: echo "${{ secrets.SCHEDULER_PROPERTIES }}" > ./backend/moment/moment-server/scheduler/src/main/resources/application.properties


# - run: cat ./src/main/resources/application.properties

- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build

- name: Deploy to Server
uses: actions/checkout@v3

- run: docker-compose up --build

# 서버에 애플리케이션 배포 스크립트 실행
# 예: scp, SSH, Docker, Kubernetes 등을 사용하여 배포
deploy:

runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v3
- name: Add Server key
run: |
touch key.txt && echo "${{ secrets.SERVER_KEY }}" > key.txt
chmod 600 key.txt
- name: Deploy the application
env:
SERVER_HOST: ${{ secrets.SERVER_HOST }}
SERVER_PORT: ${{ secrets.SERVER_PORT }}
SERVER_USER: ${{ secrets.SERVER_USER }}
run: |
chmod 755 ./deploy.sh
set -e
./deploy.sh
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/capstone-2024-22.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 0 additions & 26 deletions backend/.github/.workflows/deploy.yml

This file was deleted.

6 changes: 6 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ssh -tt -p ${SERVER_PORT} ${SERVER_USER}@${SERVER_HOST} -i key.txt -o StrictHostKeyChecking=no << 'ENDSSH'
cd capstone-2024-22
git pull origin "deploy/v1"
docker-compose up --build -d
ENDSSH

0 comments on commit ec0ec87

Please sign in to comment.