Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build: #BBB-142 CI/CD 수정 #63

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 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,27 @@ jobs:

- name: Build and Push Image to Amazon ECR
uses: docker/build-push-action@v3
id: build-and-push-image
id: build-and-push
env:
ECR: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}
with:
context: .
push: true
tags: ${{ steps.login-ecr.outputs.registry }}/${{ env.ECR_REPOSITORY }}:${{ github.sha }}
provenance: false
tags: ${{ env.ECR }}:${{ github.sha }}
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha, mode=max
cache-from: type=registry,ref=${{ env.ECR }}:cache
cache-to: type=registry,ref=${{ env.ECR }}:cache,image-manifest=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 }}
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
Loading