-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BSVR-27] 개발환경 CI/CD 세팅 #32
Merged
Merged
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b7f68fb
[BSVR-27] 개발환경 CI/CD 세팅 (#26)
pminsung12 5f50d41
[BSVR - 27] 개발환경 CI/CD ver.2 (#27)
pminsung12 6a42b1a
[BSVR-27] 개발환경 CICD v.3 (#28)
pminsung12 e4b8ea3
[BSVR-27] 개발환경 CICD ver.3 (#29)
pminsung12 ba5bfad
[BSVR-27] 개발환경 CICD ver.4 (#30)
pminsung12 2a69f41
[BSVR-27] 개발환경 CICD ver.5 (#31)
pminsung12 632a77d
Merge branch 'main' into dev
pminsung12 bb63a08
ci: 안쓰는 워크플로우 삭제
pminsung12 ee1e803
ci: 개발환경 cicd에 github release 자동화
pminsung12 ee1ea1a
ci: 운영환경 deploy 자동화 스크립트
pminsung12 298dd69
fix: personal access token에서 github token으로 변경
pminsung12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: Build And Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
- main | ||
pull_request: | ||
branches: | ||
- dev | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: "corretto" | ||
|
||
- name: Cache Gradle | ||
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: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test --stacktrace --parallel | ||
|
||
- name: Run tests | ||
run: ./gradlew test | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: JUnit Report Action | ||
uses: mikepenz/action-junit-report@v3 | ||
if: always() | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Store test results | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Test Report Summary | ||
if: always() | ||
run: | | ||
echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
./gradlew test --console=plain || true | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
|
||
deploy: | ||
needs: build-and-test | ||
if: github.ref == 'refs/heads/dev' && github.event_name == 'push' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Login to DockerHub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} | ||
|
||
- name: Deploy to Dev NCP Server | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.DEV_NCP_SERVER_HOST }} | ||
username: ${{ secrets.DEV_NCP_SERVER_USERNAME }} | ||
password: ${{ secrets.DEV_NCP_SERVER_PASSWORD }} | ||
port: ${{ secrets.DEV_NCP_SERVER_PORT }} | ||
script: | | ||
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} | ||
docker stop spot-server-dev || true | ||
docker rm spot-server-dev || true | ||
docker run -d --name spot-server-dev \ | ||
-p 8080:8080 \ | ||
-e SPRING_DATASOURCE_URL=${{ secrets.DEV_DB_URL }} \ | ||
-e SPRING_DATASOURCE_USERNAME=${{ secrets.DEV_DB_USERNAME }} \ | ||
-e SPRING_DATASOURCE_PASSWORD=${{ secrets.DEV_DB_PASSWORD }} \ | ||
-e TZ=Asia/Seoul \ | ||
${{ secrets.DOCKERHUB_USERNAME }}/spot-server:dev-${{ github.sha }} | ||
docker system prune -af |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Build And Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: "17" | ||
distribution: "corretto" | ||
|
||
- name: Cache Gradle | ||
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: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test --stacktrace --parallel | ||
|
||
- name: Run tests | ||
run: ./gradlew test | ||
|
||
- name: Publish Unit Test Results | ||
uses: EnricoMi/publish-unit-test-result-action@v2 | ||
if: always() | ||
with: | ||
files: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: JUnit Report Action | ||
uses: mikepenz/action-junit-report@v3 | ||
if: always() | ||
with: | ||
report_paths: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Store test results | ||
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: test-results | ||
path: '**/build/test-results/test/TEST-*.xml' | ||
|
||
- name: Test Report Summary | ||
if: always() | ||
run: | | ||
echo '## Test Report Summary' >> $GITHUB_STEP_SUMMARY | ||
echo '```' >> $GITHUB_STEP_SUMMARY | ||
./gradlew test --console=plain || true | ||
echo '```' >> $GITHUB_STEP_SUMMARY |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 빌드 스테이지 | ||
FROM gradle:7.4-jdk17 AS build | ||
WORKDIR /app | ||
COPY . . | ||
RUN ./gradlew build -x test | ||
|
||
# 실행 스테이지 | ||
FROM openjdk:17-jdk-slim | ||
WORKDIR /app | ||
COPY --from=build /app/application/build/libs/*.jar app.jar | ||
EXPOSE 8080 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
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 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 |
---|---|---|
|
@@ -19,6 +19,7 @@ spring: | |
init: | ||
mode: never # 필요한 경우 'never'로 변경 | ||
|
||
|
||
server: | ||
port: 8080 | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
완전 사소한건데 cicd 대신 build-and-deploy로 파일 이름 바꾸는건 어때?! 좀 더 직관적으로다가..!