Merge pull request #6 from fine-ants/feat/#4-openid #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci-cd | |
on: | |
push: | |
branches: [ dev-cicd, dev ] | |
permissions: | |
contents: read | |
env: | |
S3_BUCKET_NAME: fine-ants | |
AWS_REGION: ap-northeast-2 | |
CODEDEPLOY_NAME: fineAnts | |
CODEDEPLOY_GROUP: fineAnts-group | |
jobs: | |
build-image: | |
runs-on: ubuntu-latest | |
environment: dev | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v3 | |
## JDK 설정 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
# gradle caching - 빌드 시간 향상 | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
# 캐시할 디렉토리 경로를 지정합니다. | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
# 캐시를 구분하는 키를 지정합니다. | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
# 이전에 생성된 캐시를 복원하는데 사용할 키를 지정합니다. | |
# 캐시가 없거나 만료되었을때 이 키를 기반으로 이전에 생성된 캐시를 찾아 복원합니다. | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# 환경별 yml 파일 생성(1) - application-secret.yml | |
- name: make application-secret.yml | |
run: | | |
cd ./src/main/resources | |
touch ./application-secret.yml | |
echo "${{ secrets.APPLICATION_SECRET }}" > ./application-secret.yml | |
shell: bash | |
# env 파일 생성 | |
- name: make .env file | |
run: | | |
touch .env | |
echo "${{ secrets.ENV }}" > ./.env | |
# gradlew 실행을 위해서 실행 권한을 부여 | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
# Gradle을 이용하여 빌드 수행 | |
- name: Build with Gradle | |
run: ./gradlew bootJar | |
# zip 파일 생성 | |
- name: Make zip file | |
run: zip -r ./$GITHUB_SHA.zip . | |
# AWS 인증정보 설정 | |
- 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: ${{ env.AWS_REGION }} | |
# S3에 업로드 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip | |
# 코드 배포 | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name $CODEDEPLOY_NAME --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name $CODEDEPLOY_GROUP --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip |