Files
clean-architecture-backend-…/.gitea/actions/setup-java-gradle/action.yml
T
DongHyeonka d237bacc14 ci: JDK 캐시는 main에서만 저장한다
앞 커밋은 pull request만 읽기 전용으로 두고 push·schedule·수동 실행은 어느
브랜치에서든 저장하게 했다. 키가 Temurin 빌드 하나로 고정이고 처음 저장한
항목이 계속 쓰이므로, 쓰기 권한자가 브랜치에서 수동 실행으로 먼저 저장하면
그 뒤 모든 main 실행이 리뷰 없이 그 JDK를 복원한다. setup-gradle과 같은
규칙(main ref만 저장)으로 맞춘다.

위험·한계: 브랜치의 수동 실행에서는 main이 저장하기 전까지 캐시가 비어 있어
효과를 볼 수 없다. 효과는 병합 뒤 첫 main push에서 확인한다.
2026-11-12 01:28:35 +09:00

44 lines
2.6 KiB
YAML

name: Set up Java and Gradle
description: >-
Installs the repository's pinned Temurin JDK, then configures Gradle through the official
setup-gradle action, which validates every checked-in wrapper jar and manages the Gradle cache.
# A Gradle job is two lines: checkout, then this action. `actions/checkout` cannot move in here: a
# `./.gitea/actions/...` reference is resolved from the checked-out working copy, so this file does
# not exist until checkout has run.
#
# Full URLs, because the runner resolves a bare `owner/name` against its own default action host,
# and a pinned commit SHA, the only immutable action reference. The JDK is the version in
# .tool-versions under the name Temurin publishes it (`+10.0.LTS`); setup-java rejects `+10`.
# The JDK comes from the runner's cache when it can. Every job starts in a fresh container, so
# setup-java found an empty tool cache and downloaded the same 190 MB from GitHub in every job (about
# 22 of the 25 seconds a job spent before Gradle, and the step that failed with 504s). setup-java
# looks in the tool cache first, so restoring the directory it installs into is enough. Only a run
# on main saves the entry, the rule setup-gradle follows below: the key is fixed and the first entry
# saved under it stays, so a branch that saved it first would decide the JDK every later main run
# restores, without review.
runs:
using: composite
steps:
- if: ${{ github.ref == 'refs/heads/main' }}
uses: https://github.com/actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache@v4.3.0
with:
path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
key: jdk-temurin-21.0.11+10.0.LTS-${{ runner.os }}-${{ runner.arch }}
- if: ${{ github.ref != 'refs/heads/main' }}
uses: https://github.com/actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # actions/cache/restore@v4.3.0
with:
path: /opt/hostedtoolcache/Java_Temurin-Hotspot_jdk
key: jdk-temurin-21.0.11+10.0.LTS-${{ runner.os }}-${{ runner.arch }}
- uses: https://github.com/actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # actions/setup-java@v4.7.1
with:
distribution: temurin
java-version: "21.0.11+10.0.LTS"
# Gradle's own caching, not setup-java's `cache: gradle`. The two cache the same directory with
# different keys, and running both is how a job restores one cache and saves the other.
- uses: https://github.com/gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # gradle/actions@v6
with:
build-scan-publish: false
cache-read-only: ${{ github.ref != 'refs/heads/main' }}