Skip to content

Commit bd2934c

Browse files
authored
infra: CI/CD 캐싱 도입
* infra: CI workflow 캐싱 도입 * infra: CI/CD workflow 캐싱 도입
1 parent 7f3050a commit bd2934c

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,26 @@ jobs:
1818
java-version: '21'
1919
cache: gradle
2020

21+
- name: Cache Gradle packages
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
28+
restore-keys: |
29+
${{ runner.os }}-gradle-
30+
31+
- name: Cache Gradle Build
32+
uses: actions/cache@v3
33+
with:
34+
path: build
35+
key: ${{ runner.os }}-gradle-build-${{ github.sha }}
36+
restore-keys: |
37+
${{ runner.os }}-gradle-build-
38+
2139
- name: Grant execute permission for gradlew
2240
run: chmod +x gradlew
2341

2442
- name: Build with Gradle
25-
run: ./gradlew clean build
43+
run: ./gradlew clean build --build-cache

.github/workflows/cicd.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,40 @@ jobs:
1111
- name: Checkout code
1212
uses: actions/[email protected]
1313

14+
- name: Set up JDK 21
15+
uses: actions/[email protected]
16+
with:
17+
distribution: 'temurin'
18+
java-version: '21'
19+
cache: gradle
20+
21+
- name: Cache Gradle packages
22+
uses: actions/cache@v3
23+
with:
24+
path: |
25+
~/.gradle/caches
26+
~/.gradle/wrapper
27+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
28+
restore-keys: |
29+
${{ runner.os }}-gradle-
30+
31+
- name: Set up Docker Buildx
32+
uses: docker/setup-buildx-action@v3
33+
1434
- name: Log in to Docker Hub
1535
uses: docker/[email protected]
1636
with:
1737
username: ${{ secrets.DOCKER_USERNAME }}
1838
password: ${{ secrets.DOCKER_PASSWORD }}
1939

40+
- name: Cache Docker layers
41+
uses: actions/cache@v3
42+
with:
43+
path: /tmp/.buildx-cache
44+
key: ${{ runner.os }}-buildx-${{ github.sha }}
45+
restore-keys: |
46+
${{ runner.os }}-buildx-
47+
2048
- name: Build and Push Docker image
2149
if: github.ref == 'refs/heads/main'
2250
uses: docker/[email protected]
@@ -26,11 +54,17 @@ jobs:
2654
push: true
2755
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.PROD_IMAGE_NAME }}:latest
2856
platforms: linux/amd64
57+
cache-from: type=local,src=/tmp/.buildx-cache
58+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
59+
60+
- name: Move cache
61+
run: |
62+
rm -rf /tmp/.buildx-cache
63+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
2964
3065
deploy:
3166
runs-on: ubuntu-latest
3267
needs: build
33-
3468
steps:
3569
- name: SSH to Server and Deploy
3670
if: github.ref == 'refs/heads/main'

0 commit comments

Comments
 (0)