-
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.
* feat: ci-cd 배포 파일 분리 * feat: pr,push시에 영향받는 파일 내용 수정 * feat: ci-cd 변경 감지하는 파일 내용 수정 * feat: ci-cd redis 관련 속성 추가 * feat: ci-cd 파일 분리
- Loading branch information
Showing
5 changed files
with
161 additions
and
12 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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
name: Admin-App CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
paths-ignore: | ||
- application/ticket-app-api/** | ||
- application/queue-app-api/** | ||
|
||
env: | ||
DOCKER_REGISTRY_URL: ${{ secrets.ADMIN_DOCKER_REGISTRY_URL }} | ||
DOCKER_IMAGE_NAME: admin-uket | ||
DOCKER_CONTAINER_NAME: admin-uket | ||
|
||
jobs: | ||
build-and-push-docker-image: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
# Caching Gradle dependencies to speed up the build process | ||
- 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- | ||
# Setting up JDK 21 for building the Java application | ||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
# Ensuring the Gradle wrapper script is executable | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
# Building the application with Gradle | ||
- name: Build with Gradle | ||
run: ./gradlew clean build -PmainClass=com.uket.AdminApiApplication | ||
|
||
# Configuring AWS credentials for accessing AWS services | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_ADMIN }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_ADMIN }} | ||
aws-region: ap-northeast-2 | ||
|
||
# Logging in to Amazon ECR | ||
- name: Login to Amazon ECR | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
# Building and pushing Docker image to ECR | ||
- name: Docker build and push | ||
run: | | ||
cd ./application/admin-app-api | ||
docker build --platform linux/amd64 -t ${{ env.DOCKER_IMAGE_NAME }} . | ||
docker tag ${{ env.DOCKER_IMAGE_NAME }}:latest ${{ env.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:latest | ||
docker push ${{ env.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:latest | ||
echo "::set-output name=image::${{ env.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }}:latest" | ||
deploy: | ||
needs: build-and-push-docker-image | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Deploying the Docker container via SSH | ||
- name: Deploy via SSH | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.SSH_HOST_ADMIN }} | ||
username: ubuntu | ||
key: ${{ secrets.SSH_PRIVATE_KEY_ADMIN }} | ||
script: | | ||
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ env.DOCKER_REGISTRY_URL }} | ||
docker-compose down | ||
docker pull ${{ env.DOCKER_REGISTRY_URL }}/${{ env.DOCKER_IMAGE_NAME }} | ||
docker-compose up -d | ||
# Cleaning up unused Docker images | ||
docker image prune -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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Ticket-App CI | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
- dev | ||
paths-ignore: | ||
- application/admin-app-api/** | ||
- application/queue-app-api/** | ||
|
||
env: | ||
DOCKER_IMAGE_NAME: dev-uket | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
redis: | ||
image: redis | ||
ports: | ||
- 6379:6379 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- 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: Set up JDK 21 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '21' | ||
distribution: 'temurin' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle (Without Deployment) | ||
run: ./gradlew clean build -PmainClass=com.uket.TicketApiApplication -x test | ||
|
||
- name: Run Tests | ||
run: ./gradlew test -PmainClass=com.uket.TicketApiApplication |
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