Skip to content

Commit

Permalink
Merge pull request #375 from Team-Sopetit/deploy/chan/#374
Browse files Browse the repository at this point in the history
[DEPLOY] 개발 서버 CI/CD
  • Loading branch information
Chan531 authored Jan 30, 2025
2 parents 3f71d2c + 6426633 commit 8ebf552
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
68 changes: 37 additions & 31 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: deploy

on:
release:
types:
- published
push:
branches: [ "develop" ]

jobs:
build:
Expand All @@ -27,35 +26,42 @@ jobs:
echo "${{ secrets.APPLICATION_SECRET_YML }}" >> src/main/resources/application-secret.yml
cat src/main/resources/application-secret.yml
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1-node16
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.ACCESS_KEY_SECRET }}
aws-region: ap-northeast-2

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: build
run: |
chmod +x gradlew
./gradlew build -x test
working-directory: ${{ env.working-directory }}
shell: bash

- name: Build with Gradle
run: ./gradlew build
shell: bash

- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash
- name: docker build 환경 설정
uses: docker/setup-buildx-action@v2.9.1

- name: Upload to AWS S3
run: |
aws deploy push \
--application-name sopetit-codedeploy \
--ignore-hidden-files \
--s3-location s3://${{ secrets.AWS_BUCKET_NAME }}/$GITHUB_SHA.zip \
--source .
- name: Code Deploy
run: aws deploy create-deployment --application-name sopetit-codedeploy
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name sopetit-group
--s3-location bucket=${{ secrets.AWS_BUCKET_NAME }},bundleType=zip,key=$GITHUB_SHA.zip
- name: docker hub 로그인
uses: docker/login-action@v2.2.0
with:
username: ${{ secrets.DOCKER_LOGIN_USERNAME }}
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }}

- name: docker image 빌드 및 푸시
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile-Dev
push: true
tags: ${{ secrets.DOCKER_LOGIN_USERNAME }}/dev

cd:
needs: ci
runs-on: ubuntu-22.04

steps:
- name: docker 컨테이너 실행
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_IP }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SERVER_KEY }}
script: |
cd ~
./deploy.sh
4 changes: 4 additions & 0 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM amd64/amazoncorretto:17
WORKDIR /app
COPY ./build/libs/server-0.0.1-SNAPSHOT.jar /app/Sofite.jar
CMD ["java", "-Duser.timezone=Asia/Seoul" ,"-jar", "-Dspring.profiles.active=dev","Sofite.jar"]

0 comments on commit 8ebf552

Please sign in to comment.