Skip to content

Commit

Permalink
chore: enable github action CD pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
h-beeen committed Dec 2, 2024
1 parent 5db4bfc commit 2a1d5c8
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 50 deletions.
100 changes: 50 additions & 50 deletions .github/workflows/Continuous Delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,60 +15,60 @@ jobs:
runs-on: ubuntu-latest
name: Deploy to Amazon ECS
steps:
# - name: Checkout code
# uses: actions/checkout@v3
# with:
# token: ${{ secrets.GIT_TOKEN }}
# submodules: true
- name: Checkout code
uses: actions/checkout@v3
with:
token: ${{ secrets.GIT_TOKEN }}
submodules: true

- name: Setup Jdk 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'adopt'

# - name: Configure AWS Credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# role-to-assume: arn:aws:iam::125183404358:role/VacgomGithubActionAssumeRole
# aws-region: ap-northeast-2
#
# - name: Login to Amazon ECR
# id: login-ecr
# uses: aws-actions/amazon-ecr-login@v1
#
# - name: Invoke Gradle
# uses: gradle/gradle-build-action@v2
#
# - name: Grant execute permission for gradlew
# run: chmod +x gradlew
#
# - name: Build, tag, and push image to Amazon ECR
# env:
# PROFILE: prod
# IMAGE_REPO_URL: ${{ steps.login-ecr.outputs.registry }}/vacgom-ecr-new
# IMAGE_TAG: ${{ github.sha }}
# run: ./gradlew jib --parallel
#
# - name: Download Task Definition
# run: |
# aws ecs describe-task-definition \
# --task-definition vacgom-taskdef-new \
# --query taskDefinition \
# > task-definition.json
#
# - name: Update Task Definition
# id: task-def
# uses: aws-actions/amazon-ecs-render-task-definition@v1
# with:
# task-definition: task-definition.json
# container-name: vacgom-backend
# image: ${{ steps.login-ecr.outputs.registry }}/vacgom-ecr-new:${{ github.sha }}
#
# - name: Deploy Amazon ECS task definition
# uses: aws-actions/amazon-ecs-deploy-task-definition@v1
# with:
# task-definition: ${{ steps.task-def.outputs.task-definition }}
# service: new-vacgom-wow
# cluster: vacgom-cluster-2
# wait-for-service-stability: true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::125183404358:role/VacgomGithubActionAssumeRole
aws-region: ap-northeast-2

- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Invoke Gradle
uses: gradle/gradle-build-action@v2

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build, tag, and push image to Amazon ECR
env:
PROFILE: prod
IMAGE_REPO_URL: ${{ steps.login-ecr.outputs.registry }}/vacgom-ecr-new
IMAGE_TAG: ${{ github.sha }}
run: ./gradlew jib --parallel

- name: Download Task Definition
run: |
aws ecs describe-task-definition \
--task-definition vacgom-taskdef-new \
--query taskDefinition \
> task-definition.json
- name: Update Task Definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: vacgom-backend
image: ${{ steps.login-ecr.outputs.registry }}/vacgom-ecr-new:${{ github.sha }}

- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: new-vacgom-wow
cluster: vacgom-cluster-2
wait-for-service-stability: true
25 changes: 25 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
val activeProfile = System.getenv("PROFILE") ?: "product"
val imageTag = System.getenv("IMAGE_TAG") ?: "latest"
val repoURL: String? = System.getenv("IMAGE_REPO_URL")

plugins {
id("org.springframework.boot") version "3.3.6"
id("io.spring.dependency-management") version "1.1.6"
id("io.freefair.lombok") version "8.10.2"
id("com.google.cloud.tools.jib") version "3.4.3"

kotlin("jvm") version "2.0.21"
kotlin("plugin.jpa") version "2.0.21"
Expand Down Expand Up @@ -77,3 +82,23 @@ tasks {
dependsOn("initConfiguration")
}
}

jib {
from {
image = "amazoncorretto:21-alpine-jdk"
}
to {
image = repoURL
tags = setOf(imageTag)
}
container {
jvmFlags =
listOf(
"-Dspring.profiles.active=$activeProfile",
"-Dserver.port=8080",
"-XX:+UseContainerSupport",
"-Duser.timezone=Asia/Seoul"
)
ports = listOf("8080")
}
}

0 comments on commit 2a1d5c8

Please sign in to comment.