[Fix] 머지 이후 오류를 해결한다 #89
Workflow file for this run
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: carGive Dev CI/CD | |
permissions: | |
checks: write | |
pull-requests: write | |
on: | |
pull_request: | |
types: | |
[ opened, synchronize, reopened, closed ] | |
workflow_dispatch: # (2) 수동 실행 | |
jobs: | |
test: | |
runs-on: ubuntu-latest # (3) OS환경 | |
env: | |
S3_BUCKET_NAME: ${{secrets.S3_BUCKET_NAME}} | |
S3_ACCESS_KEY: ${{secrets.S3_ACCESS_KEY}} | |
S3_SECRET_KEY: ${{secrets.S3_SECRET_KEY}} | |
if: startsWith(github.head_ref, 'feature/') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 # (4) 코드 check out : 스프링부트 프로젝트의 소스코드를 내려받는다 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: adopt-hotspot # (5) 자바 설치 | |
- name: Cache Gradle packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash # (6) 권한 부여 | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
shell: bash # (8) build 시작 | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" # (9) build 시점의 시간확보 | |
- name: Show Current Time | |
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" | |
shell: bash # (10) 확보한 시간 보여주기 | |
- name: Code Test | |
run: ./gradlew test | |
shell: bash # (11) 테스트 코드 실행 | |
- name: Publish Unit Test Results | |
uses: EnricoMi/publish-unit-test-result-action@v1 | |
if: ${{ always() }} # 테스트가 실패하여도 Report를 보기 위해 `always`로 설정 | |
with: | |
files: build/test-results/**/*.xml | |
- name: Cleanup Gradle Cache | |
if: ${{ always() }} | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties | |
build: | |
runs-on: ubuntu-latest # (3) OS환경 | |
env: | |
S3_BUCKET_NAME: ${{secrets.S3_BUCKET_NAME}} | |
S3_ACCESS_KEY: ${{secrets.S3_ACCESS_KEY}} | |
S3_SECRET_KEY: ${{secrets.S3_SECRET_KEY}} | |
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 # (4) 코드 check out : 스프링부트 프로젝트의 소스코드를 내려받는다 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 # (5) 자바 설치 | |
distribution: adopt-hotspot | |
- name: Cache Gradle packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash # (6) 권한 부여 | |
- name: Build with Gradle | |
run: ./gradlew clean bootjar -Pprofile=prod | |
shell: bash # (8) build 시작 | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" # (9) build 시점의 시간확보 | |
- name: Show Current Time | |
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" | |
shell: bash # (10) 확보한 시간 보여주기 | |
- name: Generate deployment package | |
run: | | |
mkdir -p deploy | |
cp build/libs/*.jar deploy/application.jar | |
cp Procfile deploy/Procfile | |
cp -r .ebextensions deploy/.ebextensions | |
cp -r .platform deploy/.platform | |
cd deploy && zip -r deploy.zip . | |
- name: Beanstalk Deploy | |
uses: einaregilsson/beanstalk-deploy@v20 | |
with: | |
aws_access_key: ${{secrets.AWS_ACCESS_KEY}} | |
aws_secret_key: ${{secrets.AWS_SECRET_KEY}} | |
application_name: carGiveBeanstalk | |
environment_name: CarGiveBeanstalk-env | |
version_label: github-action-${{steps.current-time.outputs.formattedTime}} | |
region: ap-northeast-2 | |
deployment_package: deploy/deploy.zip | |
wait_for_environment_recovery: 60 | |
- name: Cleanup Gradle Cache | |
if: ${{ always() }} | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties |