Skip to content

๐Ÿ‘ท Update CI.yml #9

๐Ÿ‘ท Update CI.yml

๐Ÿ‘ท Update CI.yml #9

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
paths:
- '**/application*.yml'
env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: mapddang-s3
AWS_CODE_DEPLOY_APPLICATION: mapddang-CD
AWS_CODE_DEPLOY_GROUP: mapddang-CD-group
jobs:
build-with-gradle:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
# ์ฒดํฌ์•„์›ƒ
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
#JDK 17 ์„ค์ •
java-version: '17'
distribution: 'corretto'
#yml ํŒŒ์ผ
- name: Set yml
run: mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > src/main/resources/application-db.yml
find src
#gradlew ํŒŒ์ผ์— ์‹คํ–‰ ๊ถŒํ•œ ๋ถ€์—ฌ
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
#ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ(test ์ œ์™ธ)
- name: Build Project
run: ./gradlew clean build -x test
#AWS ์ž๊ฒฉ์ฆ๋ช… ์„ค์ •
- name: Setup AWS credential
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.EC2_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.EC2_SECRET_KEY }}
aws-region: ap-northeast-2
#ZIP ํŒŒ์ผ์„ S3 ๋ฒ„ํ‚ท์— ์—…๋กœ๋“œ
- name: Upload to AWS S3
run: aws deploy push --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --ignore-hidden-files --s3-location s3://$AWS_S3_BUCKET/cicdtest/$GITHUB_SHA.zip --source .
#์—…๋กœ๋“œ๋œ ZIP ํŒŒ์ผ์„ CodeDeploy๋กœ ๋ฐฐํฌ
- name: AWS Code Deploy
run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=$AWS_S3_BUCKET,key=cicdtest/$GITHUB_SHA.zip,bundleType=zip