๐ง ๊ฐ๋ฐ์์ฉ ์ ํ๊ณ์ sub๊ฐ์ ๋ณด๊ธฐ์ํ ์์ ๋ก๊ทธ ์ถ๊ฐ #162
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
AWS_REGION: ap-northeast-2 | |
AWS_S3_BUCKET: ${{ secrets.AWS_BUCKET_NAME }} | |
AWS_CODE_DEPLOY_APPLICATION: mapddang-CD | |
AWS_CODE_DEPLOY_GROUP: mapddang-CD-group | |
MYSQL_URL: ${{ secrets.MYSQL_URL }} | |
MYSQL_USERNAME: ${{ secrets.MYSQL_USERNAME }} | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
APPLE_CLIENT_ID: ${{ secrets.APPLE_CLIENT_ID }} | |
APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }} | |
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} | |
APPLE_PRIVATE_KEY: ${{ secrets.APPLE_PRIVATE_KEY }} | |
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }} | |
ACCESS_TOKEN_EXPIRE: ${{ secrets.ACCESS_TOKEN_EXPIRE }} | |
REFRESH_TOKEN_EXPIRE: ${{ secrets.REFRESH_TOKEN_EXPIRE }} | |
AWS_S3_ACCESS_KEY: ${{ secrets.AWS_S3_ACCESS_KEY }} | |
AWS_S3_SECRET_KEY: ${{ secrets.AWS_S3_SECRET_KEY }} | |
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: | |
java-version: '17' | |
distribution: 'corretto' | |
#๋น๋ ์บ์ | |
- name: Cache Gradle packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle- | |
#gradlew ํ์ผ์ ์คํ ๊ถํ ๋ถ์ฌ | |
- name: Grant execute permission to gradlew | |
run: chmod +x ./gradlew | |
#todo build + 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.AWS_S3_ACCESS_KEY }} | |
aws-secret-access-key: ${{ secrets.AWS_S3_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,bundleType=zip,key=cicdtest/$GITHUB_SHA.zip |