-
Notifications
You must be signed in to change notification settings - Fork 0
[Infra] - ci/cd, ec2, alb, mysql, logging, monitoring, nginx #5
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
Changes from all commits
e748bec
6ed5066
6a40f80
9de9168
b13ee51
4931eaf
6a65c48
e150069
35f5834
4ef80ab
6c2b6a0
41f50aa
9b900b1
7615f0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| name: CD API DEV | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ develop ] | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| api_changed: ${{ steps.filter.outputs.api }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - id: filter | ||
| uses: dorny/paths-filter@v3 | ||
| with: | ||
| filters: | | ||
| api: | ||
| - 'api/**' | ||
|
Comment on lines
+7
to
+19
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal, api용 브랜치를 나누지 않기로 했으니, 이전에 논의했던 대로 파일 변경이 생긴 경우에만 trigger되도록 cd 파일을 분리했습니다. 찾아보니까 특정 폴더에 파일 변경이 생겼는지 알아보기 위해 dorny/paths-filter라는 액션을 많이 사용하길래 적용해봤습니다!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오 확정이었을까요?? 전에 말씀드린 것처럼 dev -> prod 로 merge 될때 각 모듈이 따로 배포 될 수 있도록 조절이 가능한 것일까요?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 그 부분을 놓치고 구현했네요 😅 이거 혹시 좀 더 구체적인 상황을 예시들어주실 수 있나요? 제가 좀 헷갈려서요 ㅠ |
||
|
|
||
| build-api: | ||
| needs: detect-changes | ||
| if: needs.detect-changes.outputs.api_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'corretto' | ||
| java-version: '17' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Grant execute permission for run-test-mysql-redis.sh | ||
| run: chmod +x run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Run test mysql redis script | ||
| run: ./run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Test & Build api only | ||
| run: ./gradlew :api:build | ||
|
|
||
| - name: Sign in Dockerhub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
Comment on lines
+50
to
+51
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네네 좋습니다!! 이슈, PR 템플릿도 organization 기준으로 설정 가능하던데, 고것도 한번 참고해서 적용하면 좋을 거 같네요! |
||
|
|
||
| - name: Build the Docker image | ||
| run: docker build -f ./Dockerfile --platform linux/amd64 --no-cache -t samhap/kokomen-notification-api:dev . | ||
| working-directory: ./api | ||
|
|
||
| - name: Push the Docker Image to Dockerhub | ||
| run: docker push samhap/kokomen-notification-api:dev | ||
| working-directory: ./api | ||
|
|
||
| deploy-api: | ||
| needs: build-api | ||
| runs-on: [ self-hosted, dev-notification ] | ||
| steps: | ||
| - name: Stop existing container | ||
| run: sudo docker rm -f kokomen-notification-dev-api || true | ||
|
|
||
| - name: Remove old API Docker image | ||
| run: | | ||
| if sudo docker images samhap/kokomen-notification-api:dev -q | grep -q .; then | ||
| sudo docker rmi -f samhap/kokomen-notification-api:dev || true | ||
| fi | ||
|
|
||
| - name: pull docker compose yaml files | ||
| working-directory: /home/ubuntu | ||
| run: | | ||
| [ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git | ||
| cd kokomen-notification | ||
| git sparse-checkout init --cone | ||
| git fetch origin develop | ||
| git checkout develop | ||
| git sparse-checkout set docker/dev | ||
| git pull origin develop | ||
|
|
||
| - name: Docker Image pull | ||
| run: sudo docker pull samhap/kokomen-notification-api:dev | ||
|
|
||
| - name: Docker run | ||
| working-directory: /home/ubuntu | ||
| env: | ||
| MYSQL_ROOT_PASSWORD_DEV: ${{ secrets.MYSQL_ROOT_PASSWORD_DEV }} | ||
| SPRING_DATASOURCE_USERNAME_DEV: ${{ secrets.SPRING_DATASOURCE_USERNAME_DEV }} | ||
| SPRING_DATASOURCE_PASSWORD_DEV: ${{ secrets.SPRING_DATASOURCE_PASSWORD_DEV }} | ||
| run: | | ||
| export HOSTNAME=$(hostname) | ||
| cd kokomen-notification/docker/dev | ||
| sudo -E docker compose -f docker-compose-dev.yml up -d kokomen-notification-dev-api | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| name: CD INTERNAL DEV | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ develop ] | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| internal_changed: ${{ steps.filter.outputs.internal }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - id: filter | ||
| uses: dorny/paths-filter@v3 | ||
| with: | ||
| filters: | | ||
| internal: | ||
| - 'internal/**' | ||
|
|
||
| build-internal: | ||
| needs: detect-changes | ||
| if: needs.detect-changes.outputs.internal_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'corretto' | ||
| java-version: '17' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Grant execute permission for run-test-mysql-redis.sh | ||
| run: chmod +x run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Run test mysql redis script | ||
| run: ./run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Test & Build internal only | ||
| run: ./gradlew :internal:build | ||
|
|
||
| - name: Sign in Dockerhub | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKER_USERNAME }} | ||
| password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
|
||
| - name: Build the Docker image | ||
| run: docker build -f ./Dockerfile --platform linux/amd64 --no-cache -t samhap/kokomen-notification-internal:dev . | ||
| working-directory: ./internal | ||
|
|
||
| - name: Push the Docker Image to Dockerhub | ||
| run: docker push samhap/kokomen-notification-internal:dev | ||
| working-directory: ./internal | ||
|
|
||
| deploy-internal: | ||
| needs: build-internal | ||
| runs-on: [ self-hosted, dev-notification ] | ||
| steps: | ||
| - name: Stop existing container | ||
| run: sudo docker rm -f kokomen-notification-dev-internal || true | ||
|
|
||
| - name: Remove old INTERNAL Docker image | ||
| run: | | ||
| if sudo docker images samhap/kokomen-notification-internal:dev -q | grep -q .; then | ||
| sudo docker rmi -f samhap/kokomen-notification-internal:dev || true | ||
| fi | ||
|
|
||
| - name: pull docker compose yaml files | ||
| working-directory: /home/ubuntu | ||
| run: | | ||
| [ -d kokomen-notification ] || git clone --filter=blob:none --no-checkout https://github.com/samhap-soft/kokomen-notification.git | ||
| cd kokomen-notification | ||
| git sparse-checkout init --cone | ||
| git fetch origin develop | ||
| git checkout develop | ||
| git sparse-checkout set docker/dev | ||
| git pull origin develop | ||
|
|
||
| - name: Docker Image pull | ||
| run: sudo docker pull samhap/kokomen-notification-internal:dev | ||
|
|
||
| - name: Docker run | ||
| working-directory: /home/ubuntu | ||
| env: | ||
| MYSQL_ROOT_PASSWORD_DEV: ${{ secrets.MYSQL_ROOT_PASSWORD_DEV }} | ||
| SPRING_DATASOURCE_USERNAME_DEV: ${{ secrets.SPRING_DATASOURCE_USERNAME_DEV }} | ||
| SPRING_DATASOURCE_PASSWORD_DEV: ${{ secrets.SPRING_DATASOURCE_PASSWORD_DEV }} | ||
| run: | | ||
| export HOSTNAME=$(hostname) | ||
| cd kokomen-notification/docker/dev | ||
| sudo -E docker compose -f docker-compose-dev.yml up -d kokomen-notification-dev-internal | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -d 뒤에 애플리케이션 컨테이너만 실행하도록 구체적으로 명시했습니다 |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: CI API TEST | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| api_changed: ${{ steps.filter.outputs.api }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - id: filter | ||
| uses: dorny/paths-filter@v3 | ||
| with: | ||
| filters: | | ||
| api: | ||
| - 'api/**' | ||
|
|
||
| build: | ||
| needs: detect-changes | ||
| if: needs.detect-changes.outputs.api_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| checks: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'corretto' | ||
| java-version: '17' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Grant execute permission for run-test-mysql-redis.sh | ||
| run: chmod +x run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Run test mysql redis script | ||
| run: ./run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Test & Build api only | ||
| run: ./gradlew :api:build | ||
|
|
||
| - name: Publish Unit Test Results | ||
| uses: EnricoMi/publish-unit-test-result-action@v2 | ||
| if: ${{ always() }} | ||
| with: | ||
| files: ${{ github.workspace }}/api/build/test-results/**/*.xml | ||
| seconds_between_github_reads: 1.0 | ||
| seconds_between_github_writes: 3.0 | ||
| secondary_rate_limit_wait_seconds: 90.0 | ||
|
|
||
| - name: When test fail, comment on that code | ||
| uses: mikepenz/action-junit-report@v3 | ||
| if: always() | ||
| with: | ||
| report_paths: ${{ github.workspace }}/api/build/test-results/**/*.xml | ||
| token: ${{ github.token }} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| name: CI INTERNAL TEST | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [ main, develop ] | ||
|
|
||
| jobs: | ||
| detect-changes: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| internal_changed: ${{ steps.filter.outputs.internal }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - id: filter | ||
| uses: dorny/paths-filter@v3 | ||
| with: | ||
| filters: | | ||
| internal: | ||
| - 'internal/**' | ||
|
|
||
| build: | ||
| needs: detect-changes | ||
| if: needs.detect-changes.outputs.internal_changed == 'true' | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| checks: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: 'corretto' | ||
| java-version: '17' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Grant execute permission for run-test-mysql-redis.sh | ||
| run: chmod +x run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Run test mysql redis script | ||
| run: ./run-test-mysql-redis.sh | ||
| working-directory: ./domain | ||
|
|
||
| - name: Test & Build internal only | ||
| run: ./gradlew :internal:build | ||
|
|
||
| - name: Publish Unit Test Results | ||
| uses: EnricoMi/publish-unit-test-result-action@v2 | ||
| if: ${{ always() }} | ||
| with: | ||
| files: ${{ github.workspace }}/internal/build/test-results/**/*.xml | ||
| seconds_between_github_reads: 1.0 | ||
| seconds_between_github_writes: 3.0 | ||
| secondary_rate_limit_wait_seconds: 90.0 | ||
|
|
||
| - name: When test fail, comment on that code | ||
| uses: mikepenz/action-junit-report@v3 | ||
| if: always() | ||
| with: | ||
| report_paths: ${{ github.workspace }}/internal/build/test-results/**/*.xml | ||
| token: ${{ github.token }} |

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.
이게 변수처럼 사용돼서 아래 build-api를 돌릴지 말지 결정하게 됩니다.