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

[BE] Github Actions Gradle, Docker Build 캐싱 #127

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
14 changes: 12 additions & 2 deletions .github/workflows/backend-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: backend-pull-request

on:
pull_request:
branches: [ "main", "develop" ]
branches: [ "main", "develop", "feature/#121" ]
paths:
- 'server/**'

Expand All @@ -18,14 +18,24 @@ jobs:
- name: CheckOut
uses: actions/checkout@v4

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
uses: gradle/gradle-build-action@v2

- name: Test with Gradle Wrapper
run: ./gradlew clean build
Expand Down
21 changes: 16 additions & 5 deletions .github/workflows/backend-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: backend-push

on:
push:
branches: [ "main", "develop" ]
branches: [ "main", "develop", "feature/#121" ]
paths:
- 'server/**'

Expand All @@ -25,14 +25,24 @@ jobs:
token: ${{secrets.CONFIG_SUBMODULE_TOKEN}}
submodules: true

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

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

- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
uses: gradle/gradle-build-action@v2

- name: Test with Gradle Wrapper
run: ./gradlew test
Expand All @@ -48,8 +58,9 @@ jobs:

- name: Build and push
run: |
docker buildx build --platform linux/arm64 -t \
${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev --push .
docker buildx build --platform linux/arm64 --cache-from=type=registry,ref=${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev:cache \
--cache-to=type=registry,ref=${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev:cache,mode=max \
-t ${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev --push .

deploy:
needs: build
Expand All @@ -68,4 +79,4 @@ jobs:
run: sudo docker pull ${{ secrets.DOCKER_USERNAME }}/haengdong-backend-dev

- name: Docker run
run: sudo docker run -d -p 80:8080 --name haengdong-backend-dev haengdong/haengdong-backend-dev
run: sudo docker run -d -p 8080:8080 --name haengdong-backend-dev haengdong/haengdong-backend-dev