๐จ Refactor: ์ปค๋ฎค๋ํฐ ์ค ๊ฒ์๊ธ ๋ชฉ๋ก ๋ฐํ๊ณผ ๊ฒ์๊ธ ์ด๋ฏธ์ง ๊ด๋ จ ๋ฆฌํฉํ ๋ง #96
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: [ "develop" ] | |
env: | |
PROJECT_NAME: Growing-Pain | |
S3_BUCKET_NAME: growing-pain-bucket | |
CODE_DEPLOY_APPLICATION_NAME: growing-pain-deploy | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: growing-pain-group | |
RESOURCE_PATH: ./src/main/resources/application-dev.yml | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
# [0] JDK ์ธํ | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: 'gradle' | |
# [1] Set up Yaml File | |
- name: Set yaml file | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ${{ env.RESOURCE_PATH }} | |
env: | |
spring.datasource.url: ${{ secrets.DB_PATH }} | |
spring.datasource.username: ${{ secrets.DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | |
# [2] ์คํ ๊ถํ ๋ถ์ฌ | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash | |
# [3] ํ๋ก์ ํธ ๋น๋ | |
- name: Build with Gradle | |
run: ./gradlew build | |
shell: bash | |
# [4] Zip ํ์ผ ๋ง๋ค๊ธฐ | |
- name: Make zip file | |
run: zip -r ./$GITHUB_SHA.zip . | |
shell: bash | |
# [5] AWS ํค ์ค์ | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} | |
aws-region: ap-northeast-2 | |
# [6] ๋น๋ํ jarํ์ผ S3์ ๋ก๋ | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ env.S3_BUCKET_NAME }}/$GITHUB_SHA.zip | |
# [7] CodeDeploy์ S3์์ ํ์ผ ๋ฐ๊ณ ๋ฐฐํฌ | |
- name: Code Deploy | |
run: | | |
aws deploy create-deployment \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \ | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \ | |
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip |