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 6a0ab10
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
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
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
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 6a0ab10

Please sign in to comment.