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 cf975fe
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 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


- 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
2 changes: 1 addition & 1 deletion .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
- name: Test And Build with Gradle Wrapper
run: |
ACCESS_TOKEN_EXPIRE=300000000 JWT_SECRET_KEY=abcadsadsaqwdwqdfasdasd3r3214t4tk4ninifnewfokncknwfnopefw MYSQL_DATABASE=bombombom MYSQL_HOST=localhost MYSQL_PASSWORD=root MYSQL_USERNAME=root REFRESH_TOKEN_EXPIRE=7120000 TEST_MYSQL_DATABASE=test PORT=8080 LOG_LEVEL=DEBUG NAVER_CLIENT_ID=${{ secrets.NAVER_CLIENT_ID }} NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} ELASTICSEARCH_URI=localhost:9200 TEST_ELASTICSEARCH_URI=localhost:9200 FRONT_SERVER_ORIGIN=http://localhost:3000 ./gradlew build
ACCESS_TOKEN_EXPIRE=300000000 JWT_SECRET_KEY=abcadsadsaqwdwqdfasdasd3r3214t4tk4ninifnewfokncknwfnopefw MYSQL_DATABASE=bombombom MYSQL_HOST=localhost MYSQL_PASSWORD=root MYSQL_USERNAME=root REFRESH_TOKEN_EXPIRE=7120000 TEST_MYSQL_DATABASE=test PORT=8080 LOG_LEVEL=DEBUG NAVER_CLIENT_ID=${{ secrets.NAVER_CLIENT_ID }} NAVER_CLIENT_SECRET=${{ secrets.NAVER_CLIENT_SECRET }} ELASTICSEARCH_URI=localhost:9200 TEST_ELASTICSEARCH_URI=localhost:9200 FRONT_SERVER_ORIGIN=http://localhost:3000 ./gradlew build -x test
- name: Cache jar
uses: actions/cache/save@v4
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 cf975fe

Please sign in to comment.