Skip to content

Merge pull request #312 from GEON-PPANG/init-setting #34

Merge pull request #312 from GEON-PPANG/init-setting

Merge pull request #312 from GEON-PPANG/init-setting #34

Workflow file for this run

# 워크플로우의 이름 지정
name: DEV-GUNBBANG-SERVER CD
# 해당 workflow가 언제 실행될 것인지에 대한 트리거를 지정
on:
push:
branches: [ dev ] # main branch로 push 될 때 실행됩니다.
env:
S3_BUCKET_NAME: gunbbang-bucket-release
ZIP_FILE_NAME: dev-gunbbang-server
jobs:
build:
name: Code deployment
environment: dev
runs-on: ubuntu-latest
steps:
# 1) 워크플로우 실행 전 기본적으로 체크아웃 필요
- name: checkout
uses: actions/checkout@v3
# 2) JDK 21버전 설치, 다른 JDK 버전을 사용하다면 수정
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
# 3) 환경변수 파일 생성
- name: make application.properties 파일 생성
run: |
pwd
## create application.yml in api module
cd ./api/src/main/resources
touch ./application.yml
ls -al
cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
## create yml file in client/client-amplitude module
mkdir ./client/client-amplitude/src/main/resources
cd ./client/client-amplitude/src/main/resources
touch ./client-amplitude.yml
ls -al
cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
## create yml file in client/client-apple module
mkdir ./client/client-apple/src/main/resources
cd ./client/client-apple/src/main/resources
touch ./client-apple.yml
ls -al
cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
## create yml file in storage/db-core module
mkdir ./storage/db-core/src/main/resources
cd ./storage/db-core/src/main/resources
touch ./storage-db-core.yml
ls -al
cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
## create yml file in support/slack module
mkdir ./support/slack/src/main/resources
cd ./support/slack/src/main/resources
touch ./support-slack.yml
ls -al
cd /home/runner/work/GEON-PPANG-SERVER/GEON-PPANG-SERVER
# GitHub-Actions 에서 설정한 값을 application.yml 파일에 쓰기
echo "${{ secrets.DEV_API_APPLICATION }}" >> ./api/src/main/resources/application.yml
echo "${{ secrets.DEV_STORAGE_DB_CORE }}" >> ./storage/db-core/src/main/resources/storage-db-core.yml
echo "${{ secrets.DEV_CLIENT_AMPLITUDE }}" >> ./client/client-amplitude/src/main/resources/client-amplitude.yml
echo "${{ secrets.DEV_CLIENT_APPLE }}" >> ./client/client-apple/src/main/resources/client-apple.yml
echo "${{ secrets.DEV_SUPPORT_SLACK }}" >> ./support/slack/src/main/resources/support-slack.yml
shell: bash
# 이 워크플로우는 gradle build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle # 실제 application build(-x 옵션을 통해 test는 제외)
run: ./gradlew build -x test
# 디렉토리 생성
- name: Make Directory
run: mkdir -p dev-deploy
# Jar 파일 복사
- name: Copy Jar
run: cp ./api/build/libs/*.jar ./dev-deploy
# appspec.yml 파일 복사
- name: Copy appspec.yml
run: cp appspec.yml ./dev-deploy
# script files 복사
- name: Copy script
run: cp ./scripts/dev-deploy.sh ./dev-deploy/deploy.sh
- name: Make zip file
run: zip -r ./$ZIP_FILE_NAME.zip ./dev-deploy
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$ZIP_FILE_NAME.zip s3://$S3_BUCKET_NAME/
# Deploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
run:
aws deploy create-deployment
--application-name gunbbang-server-codedeploy
--deployment-group-name dev-gunbbang-server-codedeploy-group
--file-exists-behavior OVERWRITE
--s3-location bucket=gunbbang-bucket-release,bundleType=zip,key=$ZIP_FILE_NAME.zip
--region ap-northeast-2