fix[api-server]: 링크, 응모자, 응모자-파츠 엔티티 생성전략 IDENTITY로 수정 #74
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: Lottery-Deploy | |
on: | |
pull_request: | |
branches: [dev] # master branch에 PR을 보낼 때 실행 | |
paths: | |
- "lottery/**" | |
- "common/**" | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 17 | |
- name: 💾 Cache Gradle & Spring | |
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: Set YML | |
run: | | |
cd common | |
ls -l | |
mkdir -p src/main/resources | |
echo "${{ secrets.APPLICATION_LOCAL}}" | base64 --decode > src/main/resources/application-local.yml | |
echo "${{ secrets.APPLICATION_LOCAL_DB }}" | base64 --decode > src/main/resources/application-local-db.yml | |
echo "${{ secrets.APPLICATION_LOCAL_TOKEN }}" | base64 --decode > src/main/resources/application-local-token.yml | |
echo "${{ secrets.DEPLOY }}" | base64 --decode > src/main/resources/application-deploy.yml | |
echo "${{ secrets.DEPLOY_DB }}" | base64 --decode > src/main/resources/application-deploy-db.yml | |
echo "${{ secrets.DEPLOY_JWT_TOKEN }}" | base64 --decode > src/main/resources/application-deploy-token.yml | |
echo "${{ secrets.FIREBASE }}" | base64 --decode > src/main/resources/firebase.json | |
find src | |
cd .. | |
# Gradle wrapper 파일 실행 권한주기 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
# 테스트 후 스웨어 문서를 생성한다. | |
- name: Generate Swagger Document | |
run: | | |
./gradlew --info test | |
./gradlew mergeApiSpecs | |
./gradlew openapi3 | |
./gradlew customGenerateSwaggerUI | |
ls | |
# 테스트 후 Result를 보기위해 Publish Unit Test Results step 추가 | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v1 | |
if: ${{ always() }} # 테스트가 실패하여도 Report를 보기 위해 `always`로 설정 | |
continue-on-error: true # 이 단계가 실패해도 다음 단계로 넘어감 | |
with: | |
files: | | |
order/build/test-results/**/*.xml | |
lottery/build/test-results/**/*.xml | |
- name: JaCoCo Report | |
uses: Madrapps/[email protected] | |
continue-on-error: true # 이 단계가 실패해도 다음 단계로 넘어감 | |
with: | |
paths: lottery/build/reports/jacoco/test/jacocoTestReport.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
title: "테스트 커버리지 측정" | |
min-coverage-overall: 70 | |
min-coverage-changed-files: 50 | |
# 스웨거를 업로드한다. | |
- name: Upload to S3 | |
uses: jakejarvis/s3-sync-action@master | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_S3_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'ap-northeast-2' # 리전 정보 | |
SOURCE_DIR: 'swagger-ui-watermelon' # 업로드할 파일들이 위치한 로컬 디렉토리 | |
AWS_S3_BUCKET: 'watermelon-s3-bucket' # S3 버킷 이름 | |
# 애플리케이션을 Build 한다. | |
- name: 🔧 Build Spring server | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean lottery:build | |
# 도커로 빌드한다. | |
- name: Docker build | |
run: | | |
cd /home/runner/work/Team5-WatermelonClap-BE/Team5-WatermelonClap-BE/lottery | |
docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
docker build --no-cache --platform linux/arm64/v8 -t app . | |
docker tag app ${{secrets.DOCKER_USERNAME}}/watermelon-api-lottery:latest | |
docker push ${{secrets.DOCKER_USERNAME}}/watermelon-api-lottery:latest | |
# aws 에 업로드한다. | |
- name: deploy in aws | |
uses: appleboy/ssh-action@master | |
with: | |
key: ${{secrets.SSH_KEY}} | |
host: ${{secrets.SSH_API_LOTTERY_HOST}} | |
username: ${{secrets.SSH_USER}} | |
script: | | |
docker pull ${{ secrets.DOCKER_USERNAME }}/watermelon-api-lottery:latest | |
docker tag ${{ secrets.DOCKER_USERNAME }}/watermelon-api-lottery:latest watermelon-api-lottery:latest | |
docker stop $(docker ps -a -q) | |
docker run -i -d --log-driver=awslogs --log-opt awslogs-region=ap-northeast-2 --log-opt awslogs-group=watermelon-cloudwatch --log-opt awslogs-stream=watermelon-lottery -p 8091:8091 watermelon-api-lottery:latest | |
docker rm $(docker ps --filter 'status=exited' -a -q) | |
# 실행 중이지 않으 모든 컨테인 삭제 | |
docker image prune -a -f | |
# 사용하지않은 모든 이미지 삭제 |