Skip to content

fix: ci-cd env 적용 수정 #14

fix: ci-cd env 적용 수정

fix: ci-cd env 적용 수정 #14

Workflow file for this run

# 1 워크플로의 이름 지정
name: CI
# 2 워크플로가 시작될 조건 지정
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
DB_DOMAIN: ${{ secrets.DB_DOMAIN }}
DB_PORT: ${{ secrets.DB_PORT }}
DB_NAME: ${{ secrets.DB_NAME }}
DB_USERNAME: ${{ secrets.DB_USERNAME }}
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
DB_DDL_MODE: ${{ secrets.DB_DDL_MODE }}
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
JWT_EXPIRATION_MILLISECOND: ${{ secrets.JWT_EXPIRATION_MILLISECOND }}
JWT_TOKEN_PREFIX: ${{ secrets.JWT_TOKEN_PREFIX }}
JWT_TOKEN_HEADER: ${{ secrets.JWT_TOKEN_HEADER }}
APP_SERVER_PORT: ${{ secrets.APP_SERVER_PORT }}
APP_SERVER_ADDRESS: ${{ secrets.APP_SERVER_ADDRESS }}
jobs:
build:
runs-on: ubuntu-22.04 # 3 실행 환경 지정
#4 실행스텝지정
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '11'
# - name : Change workFlow directory
# run : |
# cd backend/dguonoff
- name: Grant execute permission for gradlew
run: |
cd backend/dguonoff && chmod +x gradlew && echo env.APP_SERVER_PORT
- name: Build with Gradle
run: |
cd backend/dguonoff && ./gradlew clean build -x test
# (4) AWS인증 (IAM사용자 Access Key, Secret Key활용)
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
# (5)빌드 결과물을 S3버킷에 업로드
- name: Upload to AWS S3
run: |
aws deploy push --application-name ${{ secrets.CODE_DEPLOY_APPLICATION_NAME }} --ignore-hidden-files --s3-location s3://${{secrets.S3_BUCKET_NAME}}/$GITHUB_SHA.zip --source .
# (6) S3버킷에 있는 파일을 대상으로 CodeDeploy실행
- name: Deploy to AWS EC2 from S3
run: |
aws deploy create-deployment --application-name ${{ secrets.CODE_DEPLOY_APPLICATION_NAME }} --deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} --s3-location bucket=${{secrets.S3_BUCKET_NAME}},key=$GITHUB_SHA.zip,bundleType=zip