Skip to content

Commit

Permalink
[BBB-142] Build: CI/CD μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
msjang4 committed Sep 23, 2024
1 parent 3387c88 commit 2e0b521
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 19 deletions.
43 changes: 26 additions & 17 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
name: Deploy to AWS ECS on Fargate

on:
push:
pull_request:
branches: [ "develop" ]
# types:
# - closed
workflow_dispatch:

jobs:
deploy:
# if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: devs-spring-boot
Expand All @@ -20,11 +22,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Restore jar
uses: actions/cache/restore@v4
with:
path: app/external-api/build/libs
key: ${{ runner.os }}-cached-jar-latest
key: ${{ runner.os }}-cached-jar-
restore-keys: ${{ runner.os }}-cached-jar-

- name: Configure AWS Credentials
Expand All @@ -42,24 +47,28 @@ jobs:
uses: docker/build-push-action@v3
id: build-and-push-image
with:
context: .
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha, mode=max

- 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-and-push-image.outputs.imageid }}
- name: log
run: echo ${{ steps.build-and-push-image.outputs.metadata.image.name }}

- 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
# - 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-and-push-image.outputs.imageid }}
#
# - 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
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Java CI with Gradle and MySQL and Elasticsearch

on:
pull_request:
branches: [ "develop" ]
# pull_request:
# branches: [ "develop" ]
workflow_dispatch:

jobs:
Expand Down
1 change: 1 addition & 0 deletions app/external-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
}
tasks.named('bootJar') {
preserveFileTimestamps = false
reproducibleFileOrder = true
enabled = true
}

Expand Down

0 comments on commit 2e0b521

Please sign in to comment.