Merge pull request #331 from catchroom/develop #246
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
on: | |
push: | |
branches: | |
- main | |
env: | |
CODE_DEPLOY_APPLICATION_NAME: CatchRoom-deploy | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: CatchRoom-Codedeployment | |
MY_ENV_VARIABLE: 'my-value' # Here is where we add the new environment variable. | |
SLACK_WEBHOOK_URI: ${{ secrets.SLACK_WEBHOOK_URI }} | |
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }} | |
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }} | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: 17 | |
distribution: 'adopt' # or 'temurin' or 'zulu' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Clean with Gradle | |
run: ./gradlew clean | |
- name: Build with Gradle | |
run: ./gradlew build --scan | |
# 전송할 파일을 담을 디렉토리 생성 | |
- name: Make Directory for deliver | |
run: mkdir deploy | |
# Jar 파일 copy | |
- name: Copy Jar | |
run: cp ./build/libs/*.jar ./deploy/ | |
- name: Copy appspec and deploy script | |
run: | | |
cp ./appspec.yml ./deploy/ | |
cp ./deploy.sh ./deploy/ | |
# 압축파일 형태로 전달 | |
- name: Make zip file | |
run: zip -r -qq -j ./$GITHUB_SHA.zip ./deploy | |
# S3 Bucket으로 Upload | |
- name: Deploy | |
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 | |
# S3 Bucket으로 copy | |
- name: Deliver to AWS S3 | |
run: aws s3 cp --region ap-northeast-2 --acl private ./$GITHUB_SHA.zip s3://catchroom-bucket/ | |
- 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=catchroom-bucket,bundleType=zip,key=$GITHUB_SHA.zip | |
# 배포 성공시 슬랙 webhook | |
- name: Slack - Send Msg | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: workflow,job,commit,repo,author,took,ref | |
author_name: CatchRoom_BE | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URI}} | |
if: always() |