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 ee5e2e8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
22 changes: 15 additions & 7 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 @@ -40,21 +45,24 @@ jobs:

- name: Build and Push Image to Amazon ECR
uses: docker/build-push-action@v3
id: build-and-push-image
id: build-and-push
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
cache-from: type=gha, scope=global
cache-to: type=gha, mode=max, scope=global


- 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 }}
image: ${{ fromJSON(steps.build-and-push.outputs.metadata)['image.name'] }}


- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ subprojects {

tasks.named('jar') {
enabled = true
preserveFileTimestamps = false
reproducibleFileOrder = true
}

tasks.named('test') {
Expand Down

0 comments on commit ee5e2e8

Please sign in to comment.