Skip to content

Commit

Permalink
Merge tag '20240608' into develop
Browse files Browse the repository at this point in the history
   20240608
  • Loading branch information
dragontaek-lee committed Jun 8, 2024
2 parents a3df2f5 + 9912481 commit 8f94a1a
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions .github/workflows/cd-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 워크플로우의 이름 지정
name: Gam-prod-server CD

# 해당 workflow가 언제 실행될 것인지에 대한 트리거를 지정
on:
push:
branches: [ main ]

jobs:
build:
name: Code deployment

# 실행 환경
runs-on: ubuntu-latest

steps:

# 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
- name: checkout
uses: actions/checkout@v3

# 2) JDK 11버전 설치, 다른 JDK 버전을 사용하다면 수정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# 3) 환경변수 파일 생성
- name: make application.properties 파일 생성
run: |
## create application.yml
cd ./src/main/resources
# application.yml 파일 생성
touch ./application-prod.yml
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.GAM_PROD_APPLICATION }}" >> ./application-prod.yml
# application.yml 파일 확인
cat ./application-prod.yml
shell: bash

# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build with Gradle
run: ./gradlew build -x test

# 디렉토리 생성
- name: Make Directory
run: mkdir -p deploy

# Jar 파일 복사
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy

# appspec.yml 파일 복사
- name: Copy appspec.yml
run: cp appspec.yml ./deploy

# script files 복사
- name: Copy script
run: cp ./scripts/*.sh ./deploy

- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip ./deploy
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_CONFIG_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_CONFIG_SECRET_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET_NAME }}/prod/$GITHUB_SHA.zip

# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CONFIG_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CONFIG_SECRET_KEY }}
run:
aws deploy create-deployment
--application-name gam-codeDeploy
--deployment-group-name prod
--file-exists-behavior OVERWRITE
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},bundleType=zip,key=prod/$GITHUB_SHA.zip
--region ap-northeast-2

0 comments on commit 8f94a1a

Please sign in to comment.