Skip to content

[BE] 백엔드 배포가 잘 되는지 테스트 (#54) #6

[BE] 백엔드 배포가 잘 되는지 테스트 (#54)

[BE] 백엔드 배포가 잘 되는지 테스트 (#54) #6

Workflow file for this run

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: backend deploy
on:
push:
branches:
- "main"
paths:
- "back/**"
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: spring-deploy-lee
CODE_DEPLOY_APPLICATION_NAME: my-codedeploy-app
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: my-codedeploy-group
jobs:
build:
runs-on: ubuntu-20.04
defaults:
run:
working-directory: ./back
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- uses: actions/checkout@v2
- run: touch ./src/main/resources/application.properties
- run: echo "${{secrets.PROPERTIES}}" > ./src/main/resources/application.properties
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # 사용하는 Python 버전 지정
- name: Install Python dependencies
run: |
pip install -r ./requirements.txt
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
# 빌드 결과물을 S3 버킷에 업로드
- name: Upload to S3
run: |
aws deploy push \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--ignore-hidden-files \
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \
--source .
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
- name: Deploy
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip