hotfix: 입금자명 마스킹 해제 #40
Workflow file for this run
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
name: Java CI/CD with Gradle | |
on: | |
push: | |
branches: | |
- dev | |
- admin | |
env: | |
AWS_REGION: ap-northeast-2 | |
# Dev branch | |
jobs: | |
build-and-push-docker-image-dev: | |
if: github.ref == 'refs/heads/dev' | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_IMAGE_NAME: dev-uket | |
DOCKER_CONTAINER_NAME: dev-uket | |
DOCKER_REGISTRY_URL: ${{ secrets.DEV_DOCKER_REGISTRY_URL }} | |
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 build -x test | |
# Configuring AWS credentials for accessing AWS services | |
- name: Configure AWS credentials for dev | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }} | |
aws-region: ${{ env.AWS_REGION }} | |
# Logging in to Amazon ECR | |
- name: Login to Amazon ECR for dev | |
uses: aws-actions/amazon-ecr-login@v1 | |
# Building and pushing Docker image to ECR | |
- name: Docker build and push for dev | |
run: | | |
cd ./application/ticket-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-dev: | |
if: github.ref == 'refs/heads/dev' | |
needs: build-and-push-docker-image-dev | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Dev EC2 via SSH | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SSH_HOST_DEV }} | |
username: ec2-user | |
key: ${{ secrets.SSH_PRIVATE_KEY_DEV }} | |
script: | | |
aws ecr get-login-password --region ${{ env.AWS_REGION }} | 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 | |
# Admin branch | |
build-and-push-docker-image-admin: | |
if: github.ref == 'refs/heads/admin' | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_IMAGE_NAME: admin-uket | |
DOCKER_CONTAINER_NAME: admin-uket | |
DOCKER_REGISTRY_URL: ${{ secrets.ADMIN_DOCKER_REGISTRY_URL }} | |
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 -x test | |
# Configuring AWS credentials for accessing AWS services | |
- name: Configure AWS credentials for admin | |
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: ${{ env.AWS_REGION }} | |
# Logging in to Amazon ECR | |
- name: Login to Amazon ECR for admin | |
uses: aws-actions/amazon-ecr-login@v1 | |
# Building and pushing Docker Image to ECR | |
- name: Docker build and push for admin | |
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-admin: | |
if: github.ref == 'refs/heads/admin' | |
env: | |
DOCKER_IMAGE_NAME: admin-uket | |
DOCKER_CONTAINER_NAME: admin-uket | |
DOCKER_REGISTRY_URL: ${{ secrets.ADMIN_DOCKER_REGISTRY_URL }} | |
needs: build-and-push-docker-image-admin | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Admin EC2 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 ${{ env.AWS_REGION }} | 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 |