feat: 카프카 consumer id를 동적으로 생성하도록 변경 #26
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 CD with Gradle in Tiki-Taza | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
env: | |
AWS_REGION: ap-northeast-2 | |
ECR_REPOSITORY: 533267244952.dkr.ecr.ap-northeast-2.amazonaws.com/tikitaza | |
ECS_CLUSTER: tikitaza-cluster | |
ECS_SERVICE: tikitaza-service-prod | |
ECS_TASK_DEFINITION: .aws/task-definition-prod.json | |
CONTAINER_NAME: tikitaza-container-prod | |
permissions: | |
contents: read | |
jobs: | |
deploy: | |
name: prod-deploy | |
runs-on: ubuntu-latest | |
environment: v1.0.0 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
## create application.yml | |
- name: make application-secret.yml | |
run: | | |
mkdir -p ./api/src/main/resources | |
touch ./api/src/main/resources/application-secret.yml | |
shell: bash | |
- name: deliver application-secret.yml | |
run: echo "${{ secrets.APPLICATION_SECRET }}" > ./api/src/main/resources/application-secret.yml | |
shell: bash | |
## gradlew 권한 부여 | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
## gradle build | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
## 현재 시간 가져오기 | |
- name: Get current time | |
uses: josStorer/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" | |
- name: Show Current Time | |
run: echo "CurrentTime=${{ steps.current-time.outputs.formattedTime }}" | |
## AWS에 로그인 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ${{ env.AWS_REGION }} | |
## ECR에 로그인 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v2 | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
run: | | |
docker build -t tikitaza:${{ steps.current-time.outputs.formattedTime }} . | |
docker tag tikitaza:${{ steps.current-time.outputs.formattedTime }} ${{ env.ECR_REPOSITORY }}:${{ steps.current-time.outputs.formattedTime }}-prod | |
docker push ${{ env.ECR_REPOSITORY }}:${{ steps.current-time.outputs.formattedTime }}-prod | |
echo "image=${{ env.ECR_REPOSITORY }}:${{ steps.current-time.outputs.formattedTime }}-prod" >> $GITHUB_OUTPUT | |
- name: Fill in the new image ID in the Amazon ECS task definition | |
id: task-def | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: ${{ env.ECS_TASK_DEFINITION }} | |
container-name: ${{ env.CONTAINER_NAME }} | |
image: ${{ steps.build-image.outputs.image }} | |
- 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: ${{ env.ECS_SERVICE }} | |
cluster: ${{ env.ECS_CLUSTER }} | |
wait-for-service-stability: true |