Skip to content

chore: update submodule #42

chore: update submodule

chore: update submodule #42

Workflow file for this run

name: Backend CD
on:
push:
branches:
- main
env:
SUBMODULE_TOKEN: ${{ secrets.SUBMODULE_TOKEN }}
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
ZIP_FILE: spring-build-${{ github.run_number }}.zip
S3_BUCKET: ${{ secrets.S3_BUCKET }}
S3_DEPLOY_RESOURCE_FOLDER: ${{ secrets.S3_DEPLOY_RESOURCE_FOLDER }}
AWS_DEPLOY_APP_NAME: ${{ secrets.AWS_DEPLOY_APP_NAME }}
AWS_DEPLOY_GROUP: ${{ secrets.AWS_DEPLOY_GROUP }}
AWS_DEPLOY_CONFIG: ${{ secrets.AWS_DEPLOY_CONFIG }}
jobs:
build-and-deploy:
name: Build & Deploy
runs-on: ubuntu-latest
steps:
- name: Repository를 가져온다
uses: actions/checkout@v3
with:
token: ${{ env.SUBMODULE_TOKEN }}
submodules: true
- name: JDK 17을 설정한다
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 17
- name: Gradle 정보를 캐싱한다
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Timezone을 Asia/Seoul로 설정한다
uses: zcong1993/setup-timezone@master
with:
timezone: Asia/Seoul
- name: Gradle 명령 실행을 위한 권한을 부여한다
run: chmod +x gradlew
- name: Gradle build를 수행한다
run: ./gradlew bootJar
- name: S3에 보낼 Resource Zip File을 생성한다
run: |
mkdir -p deploy
cp ./appspec.yml ./deploy/
cp ./Dockerfile ./deploy/
cp ./scripts/*.sh ./deploy/
cp ./build/libs/*.jar ./deploy/
zip -r -qq -j ./spring-build-${{ github.run_number }}.zip ./deploy
- name: AWS 인증을 진행한다
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ env.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ env.AWS_SECRET_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Resource Zip File을 S3로 전송한다
run: |
aws s3 cp \
--region ${{ env.AWS_REGION }} \
./${{ env.ZIP_FILE }} s3://${{ env.S3_BUCKET }}/${{ env.S3_DEPLOY_RESOURCE_FOLDER }}/${{ env.ZIP_FILE }}
- name: AWS CodeDeploy를 통한 배포를 진행한다
id: deploy
run: |
aws deploy create-deployment \
--application-name ${{ env.AWS_DEPLOY_APP_NAME }} \
--deployment-group-name ${{ env.AWS_DEPLOY_GROUP }} \
--deployment-config-name ${{ env.AWS_DEPLOY_CONFIG }} \
--s3-location bucket=${{ env.S3_BUCKET }},bundleType=zip,key=${{ env.S3_DEPLOY_RESOURCE_FOLDER }}/${{ env.ZIP_FILE }}