Skip to content

Commit

Permalink
Merge pull request #65 from Team-BomBomBom/build/cd_with_cache#BBB-142
Browse files Browse the repository at this point in the history
Build: #BBB-142 CD ์บ์‹ฑ ์ ์šฉ ์™„๋ฃŒ
  • Loading branch information
msjang4 authored Sep 24, 2024
2 parents a73d65d + 156e9f2 commit c45aed0
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 9 deletions.
49 changes: 46 additions & 3 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,52 @@
name: Deploy to AWS ECS on Fargate

on:
merge_group:
branches: [ "develop" ]
push:
branches:
[ "develop" ]
workflow_dispatch:

jobs:
deploy:
boot-jar:
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache.outputs.cache-hit }}
steps:
- uses: actions/checkout@v4

- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: gradle

- name: BootJar With Gradle Wrapper
run: ./gradlew bootJar

- name: Look up cached jar
uses: actions/cache/restore@v4
id: cache
with:
path: app/external-api/build/libs
key: ${{ runner.os }}-cached-jar-${{ hashFiles('app/external-api/build/libs/*.jar') }}
lookup-only: true

- name: Log cache step
env:
CACHE_OUTPUT: ${{ toJSON(steps.cache.outputs) }}
run: |
echo $CACHE_OUTPUT
- name: Cache jar
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache/save@v4
with:
path: app/external-api/build/libs
key: ${{ runner.os }}-cached-jar-${{ hashFiles('app/external-api/build/libs/*.jar') }}

deploy:
# jar ํŒŒ์ผ์ด ๊ฐฑ์‹ ๋œ๊ฒฝ์šฐ์—๋งŒ deploy ์ง„ํ–‰
env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: devs-spring-boot
Expand All @@ -16,6 +55,10 @@ jobs:
ECS_TASK_DEFINITION: ./devs-spring-server-task.json
CONTAINER_NAME: spring-boot

if: ${{ needs.boot-jar.outputs.cache-hit != 'true' }}
needs: boot-jar
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: Java CI with Gradle and MySQL and Elasticsearch

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

jobs:
Expand Down Expand Up @@ -66,8 +67,3 @@ jobs:
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
- name: Cache jar
uses: actions/cache/save@v4
with:
path: app/external-api/build/libs
key: ${{ runner.os }}-cached-jar-${{ hashFiles('app/external-api/build/libs/*.jar') }}

0 comments on commit c45aed0

Please sign in to comment.