자동 PR 리뷰를 위한 workflow 파일 추가 by f-lab #22
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
# 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://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle | |
name: CD NCP | |
on: | |
push: | |
branches: | |
- 'develop' | |
- 'main' | |
jobs: | |
CD: | |
## NCP OS : Ubuntu 18.04 | |
runs-on: ubuntu-18.04 | |
steps: | |
## Project JDK 11 Setting | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
## Riot Api Key 수정 | |
- name: Constants.yml Change Riot Api Key | |
run: | | |
cd ./src/main/resources | |
chmod 755 constants.yml | |
sed -i 's/riot-api-key/${{ secrets.RIOT_API_KEY }}/g' constants.yml | |
cat constants.yml | |
shell: bash | |
## Main Branch Make yml | |
## 메인 브랜치는 파일을 Repository Setting에 넣을 예정이기에 만들고 시작해야함. | |
- name: Main Branch Make application-prod.properties | |
if: contains(github.ref, 'main') | |
run: | | |
cd ./src/main/resources | |
touch ./application-prod.properties | |
echo "${{ secrets.PROPERTIES_PROD }}" > ./application-prod.properties | |
shell: bash | |
## Gradle Permission Setting | |
- name: Grant Execute permission for gradlew | |
run: chmod +x gradlew | |
shell: bash | |
## develop Branch Test | |
- name: Develop Test | |
if: contains(github.ref, 'develop') | |
run: SPRING_PROFILES_ACTIVE=[dev] ./gradlew clean test | |
shell: bash | |
## Main Branch Test | |
- name: main Test | |
if: contains(github.ref, 'main') | |
run: SPRING_PROFILES_ACTIVE=[prod] ./gradlew clean test | |
shell: bash | |
## Main, Devlop Branch Build | |
## Test이후 build를 하는 이유는 Test이후 build파일이 삭제가 되서 파일을 못찾는 문제가 발생 | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
shell: bash | |
- name: Develop Branch Copy Jar To DevServer | |
uses: appleboy/scp-action@master | |
if: contains(github.ref, 'develop') | |
with: | |
host: ${{ secrets.NCP_DEV_SERVER_IP }} | |
username: ${{ secrets.NCP_DEV_SERVER_USER }} | |
password: ${{ secrets.NCP_DEV_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_DEV_SERVER_SSH_PORT }} | |
source: "./build/libs/app.jar" | |
target: "/nooblol" | |
- name: DevServer CopyJar Run | |
uses: appleboy/ssh-action@master | |
id: deploy-dev | |
if: contains(github.ref, 'develop') | |
with: | |
host: ${{ secrets.NCP_DEV_SERVER_IP }} | |
username: ${{ secrets.NCP_DEV_SERVER_USER }} | |
password: ${{ secrets.NCP_DEV_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_DEV_SERVER_SSH_PORT }} | |
script_stop: true | |
script: | | |
cd /nooblol | |
./dev-run.sh | |
# 현재 운영서버 제작을 하지 않아 개발서버 정보로 일치화 | |
- name: Main Branch Copy Jar To DevServer | |
uses: appleboy/scp-action@master | |
if: contains(github.ref, 'main') | |
with: | |
host: ${{ secrets.NCP_DEV_SERVER_IP }} | |
username: ${{ secrets.NCP_DEV_SERVER_USER }} | |
password: ${{ secrets.NCP_DEV_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_DEV_SERVER_SSH_PORT }} | |
source: "./build/libs/app.jar" | |
target: "/nooblol" | |
- name: ProdServer CopyJar Run | |
uses: appleboy/ssh-action@master | |
id: deploy-main | |
if: contains(github.ref, 'main') | |
with: | |
host: ${{ secrets.NCP_DEV_SERVER_IP }} | |
username: ${{ secrets.NCP_DEV_SERVER_USER }} | |
password: ${{ secrets.NCP_DEV_SERVER_PASSWORD }} | |
port: ${{ secrets.NCP_DEV_SERVER_SSH_PORT }} | |
script_stop: true | |
script: | | |
cd /nooblol | |
./dev-run.sh |