Skip to content

deploy: #114 - CodeDeploy sh 실행 경로 오타 수정 #5

deploy: #114 - CodeDeploy sh 실행 경로 오타 수정

deploy: #114 - CodeDeploy sh 실행 경로 오타 수정 #5

name: CI & CD for dodal-prd
on:
push:
branches: [ "main" ]
env:
S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME_PRD }}
CODE_DEPLOY_APPLICATION_NAME: dodal-code-deploy-prd
CODE_DEPLOY_DEPLOYMENT_GROUP: deploy
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: make application-prd.yml
run: |
cd ./src/main/resources
touch ./application-prd.yml
echo "${{ secrets.APPLICATION_PRD }}" > ./application-prd.yml
touch ./application.yml
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
cd ../../test/resources
touch ./application.yml
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "dodal-fcm.json"
json: ${{ secrets.FCM_JSON }}
dir: src/main/resources
- name: Build with Gradle
run: |
./gradlew cleanQuerydslSourceDir
./gradlew build
# S3에 전송할 디렉토리 생성
- name: Make Directory for deliver
run: mkdir -p ./prd/scripts
- name: Copy Jar
run: |
chmod +x ./build/libs/*.jar
cp ./build/libs/*.jar ./prd/
cp ./deploy/appspec-prd.yml ./prd/appspec.yml
cp ./deploy/scripts/deploy-prd.sh ./prd/scripts/deploy-prd.sh
# 압축파일 형태로 전달
- name: Make zip file
run: |
cd ./prd
zip -r ./deploy-prd.zip .
# S3 Bucket으로 copy
- name: Deliver to AWS S3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_PRD }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_KEY_PRD }}
run: |
aws s3 cp \
--region ap-northeast-2 \
--acl private ./prd/deploy-prd.zip s3://${{ env.S3_BUCKET_NAME }}/deploy/deploy-prd.zip
# CodeDeploy
- name: Deploy
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CODE_DEPLOY_ACCESS_KEY_PRD }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CODE_DEPLOY_SECRET_KEY_PRD }}
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP }} \
--file-exists-behavior OVERWRITE \
--ignore-application-stop-failures \
--s3-location bucket=${{ env.S3_BUCKET_NAME }},bundleType=zip,key=deploy/deploy-prd.zip \
--region ap-northeast-2