forked from softeerbootcamp4th/Team5-WatermelonClap-BE
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: NCP용 개별 ci/cd pipleline 적용
- Loading branch information
Showing
5 changed files
with
407 additions
and
406 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,103 @@ | ||
name: Gateway-Deploy | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- deploy | ||
types: | ||
- closed | ||
paths: | ||
- "gateway/**" | ||
|
||
# push: | ||
# branches: [WB-115-api-server] # master branch에 PR을 보낼 때 실행 | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
# services: | ||
# redis: | ||
# image: redis:6.x | ||
# ports: | ||
# - 6379:6379 | ||
steps: | ||
|
||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Check if the pull request was merged | ||
id: check_pr_merged | ||
run: | | ||
# Check if the PR was merged | ||
if [[ "${{ github.event.pull_request.merged }}" == "true" ]]; then | ||
echo "pr_merged=true" >> $GITHUB_ENV | ||
else | ||
echo "pr_merged=false" >> $GITHUB_ENV | ||
fi | ||
- name: Run some action if the PR was merged | ||
if: env.pr_merged == 'true' | ||
run: | | ||
echo "The pull request was merged. Running additional actions..." | ||
- 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 gateway | ||
ls -l | ||
mkdir -p src/main/resources | ||
echo "${{ secrets.SSL_KEYSTORE }}" | base64 --decode > src/main/resources/keystore.p12 | ||
find src | ||
# Gradle wrapper 파일 실행 권한주기 | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: 🔧 Build Spring server | ||
run: | | ||
chmod +x ./gradlew | ||
./gradlew clean gateway:build | ||
- name: Docker build | ||
run: | | ||
cd /home/runner/work/Team5-WatermelonClap-BE/Team5-WatermelonClap-BE/gateway | ||
docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | ||
docker build --no-cache --platform linux/arm64 -t app . | ||
docker tag app ${{secrets.DOCKER_USERNAME}}/watermelon-api-gateway:latest | ||
docker push ${{secrets.DOCKER_USERNAME}}/watermelon-api-gateway:latest | ||
- name: deploy in aws | ||
uses: appleboy/ssh-action@master | ||
with: | ||
key: ${{secrets.SSH_KEY}} | ||
host: ${{secrets.GATEWAY_SSH_HOST}} | ||
username: ${{secrets.SSH_USER}} | ||
script: | | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/watermelon-api-gateway:latest | ||
docker tag ${{ secrets.DOCKER_USERNAME }}/watermelon-api-gateway:latest watermelon-api-gateway: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-gateway -p 8080:8080 watermelon-api-gateway:latest | ||
docker rm $(docker ps --filter 'status=exited' -a -q) | ||
# 실행 중이지 않으 모든 컨테인 삭제 | ||
docker image prune -a -f | ||
# 사용하지않은 모든 이미지 삭제 | ||
#name: Gateway-Deploy | ||
# | ||
#on: | ||
# pull_request: | ||
# branches: | ||
# - deploy | ||
# types: | ||
# - closed | ||
# paths: | ||
# - "gateway/**" | ||
# | ||
## push: | ||
## branches: [WB-115-api-server] # master branch에 PR을 보낼 때 실행 | ||
# | ||
#jobs: | ||
# deploy: | ||
# runs-on: ubuntu-latest | ||
# | ||
# # services: | ||
# # redis: | ||
# # image: redis:6.x | ||
# # ports: | ||
# # - 6379:6379 | ||
# steps: | ||
# | ||
# - name: Checkout code | ||
# uses: actions/checkout@v3 | ||
# | ||
# - name: Check if the pull request was merged | ||
# id: check_pr_merged | ||
# run: | | ||
# # Check if the PR was merged | ||
# if [[ "${{ github.event.pull_request.merged }}" == "true" ]]; then | ||
# echo "pr_merged=true" >> $GITHUB_ENV | ||
# else | ||
# echo "pr_merged=false" >> $GITHUB_ENV | ||
# fi | ||
# | ||
# - name: Run some action if the PR was merged | ||
# if: env.pr_merged == 'true' | ||
# run: | | ||
# echo "The pull request was merged. Running additional actions..." | ||
# | ||
# - 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 gateway | ||
# ls -l | ||
# mkdir -p src/main/resources | ||
# echo "${{ secrets.SSL_KEYSTORE }}" | base64 --decode > src/main/resources/keystore.p12 | ||
# find src | ||
# | ||
# # Gradle wrapper 파일 실행 권한주기 | ||
# - name: Grant execute permission for gradlew | ||
# run: chmod +x gradlew | ||
# | ||
# - name: 🔧 Build Spring server | ||
# run: | | ||
# chmod +x ./gradlew | ||
# ./gradlew clean gateway:build | ||
# | ||
# - name: Docker build | ||
# run: | | ||
# cd /home/runner/work/Team5-WatermelonClap-BE/Team5-WatermelonClap-BE/gateway | ||
# docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | ||
# docker build --no-cache --platform linux/arm64 -t app . | ||
# | ||
# docker tag app ${{secrets.DOCKER_USERNAME}}/watermelon-api-gateway:latest | ||
# docker push ${{secrets.DOCKER_USERNAME}}/watermelon-api-gateway:latest | ||
# | ||
# | ||
# - name: deploy in aws | ||
# uses: appleboy/ssh-action@master | ||
# with: | ||
# key: ${{secrets.SSH_KEY}} | ||
# host: ${{secrets.GATEWAY_SSH_HOST}} | ||
# username: ${{secrets.SSH_USER}} | ||
# script: | | ||
# docker pull ${{ secrets.DOCKER_USERNAME }}/watermelon-api-gateway:latest | ||
# docker tag ${{ secrets.DOCKER_USERNAME }}/watermelon-api-gateway:latest watermelon-api-gateway: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-gateway -p 8080:8080 watermelon-api-gateway:latest | ||
# docker rm $(docker ps --filter 'status=exited' -a -q) | ||
# # 실행 중이지 않으 모든 컨테인 삭제 | ||
# docker image prune -a -f | ||
# # 사용하지않은 모든 이미지 삭제 | ||
# |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,90 @@ | ||
name: Lottery-Test | ||
|
||
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: Test | ||
run: | | ||
./gradlew --info lottery:test | ||
- name: List files to be uploaded | ||
run: | | ||
echo "Files in lottery/build/generated-snippets/:" | ||
ls -la lottery/build/generated-snippets/ | ||
# 스웨거 소스 업로드 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v3 | ||
with: | ||
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' | ||
|
||
- name: Upload files to S3 | ||
run: | | ||
aws s3 cp lottery/build/generated-snippets/ s3://watermelon-s3-bucket/snippets/ --recursive | ||
# 테스트 후 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: 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: Lottery-Test | ||
# | ||
#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: Test | ||
# run: | | ||
# ./gradlew --info lottery:test | ||
# | ||
# - name: List files to be uploaded | ||
# run: | | ||
# echo "Files in lottery/build/generated-snippets/:" | ||
# ls -la lottery/build/generated-snippets/ | ||
# | ||
# # 스웨거 소스 업로드 | ||
# - name: Configure AWS credentials | ||
# uses: aws-actions/configure-aws-credentials@v3 | ||
# with: | ||
# 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' | ||
# | ||
# - name: Upload files to S3 | ||
# run: | | ||
# aws s3 cp lottery/build/generated-snippets/ s3://watermelon-s3-bucket/snippets/ --recursive | ||
# | ||
# # 테스트 후 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: 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 |
Oops, something went wrong.