Chore: 빌드 후 JAR파일의 이름을 변경하는 방식 채택 (#12) #9
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: TEST-CI | |
on: | |
push: | |
branches: [ "release" ] | |
env: | |
PROJECT_NAME: COTATO-BE-TEST | |
BUCKET_NAME: cotato-ci-cd-bucket-test | |
CODE_DEPLOY_APP_NAME: cotato-deploy | |
DEPLOYMENT_GROUP_NAME: cotato-deploy-group-test | |
RESOURCE_PATH: ./src/main/resources/application-stage.yml | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# [0] JDK 세팅 | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
# [1] Set up Yaml File | |
- name: Set up Yaml File | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ${{ env.RESOURCE_PATH }} | |
env: | |
spring.datasource.url: ${{ secrets.TEST_DB_PATH }} | |
spring.datasource.username: ${{ secrets.TEST_DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.TEST_DB_PWD }} | |
spring.jpa.hibernate.ddl-auto: ${{ secrets.TEST_DDL_AUTO }} | |
spring.mail.username: ${{ secrets.SENDER_EMAIL }} | |
spring.mail.password: ${{ secrets.SENDER_PASSWORD }} | |
jwt.secretKey: ${{ secrets.JWT_SECRET_KEY}} | |
cloud.aws.s3.bucket: ${{ secrets.S3_BUCKET_NAME }} | |
cloud.aws.credentials.accessKey: ${{ secrets.S3_ACCESS_KEY }} | |
cloud.aws.credentials.secretKey: ${{ secrets.S3_ACCESS_PASSWORD }} | |
aes.secret.key: ${{ secrets.AES_SECRET_KEY }} | |
aes.secret.salt: ${{ secrets.AES_SECRET_SALT }} | |
# [2] 실행 권한 부여 | |
- name: Grant permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash | |
# [3] 프로젝트 빌드 | |
- name: Build with Gradle Wrapper | |
run: ./gradlew build | |
# [3] - 1 생성된 jar 파일 이름 변경 | |
- name: Rename JAR file | |
run: mv build/libs/*.jar build/libs/csquiz-stage-0.0.1-SNAPSHOT.jar | |
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_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ secrets.AWS_REGION }} | |
# [6] 빌드한 jar파일 S3업로드 | |
- name: Upload to s3 | |
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{ env.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_APP_NAME }} --deployment-group-name ${{ env.DEPLOYMENT_GROUP_NAME }} --s3-location bucket=${{ env.BUCKET_NAME }},bundleType=zip,key=$GITHUB_SHA.zip |