ci: JDK 캐시는 main에서만 저장한다
앞 커밋은 pull request만 읽기 전용으로 두고 push·schedule·수동 실행은 어느 브랜치에서든 저장하게 했다. 키가 Temurin 빌드 하나로 고정이고 처음 저장한 항목이 계속 쓰이므로, 쓰기 권한자가 브랜치에서 수동 실행으로 먼저 저장하면 그 뒤 모든 main 실행이 리뷰 없이 그 JDK를 복원한다. setup-gradle과 같은 규칙(main ref만 저장)으로 맞춘다. 위험·한계: 브랜치의 수동 실행에서는 main이 저장하기 전까지 캐시가 비어 있어 효과를 볼 수 없다. 효과는 병합 뒤 첫 main push에서 확인한다.
This commit is contained in:
@@ -14,20 +14,19 @@ description: >-
|
||||
# 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. A pull
|
||||
# request only reads the entry, so code under review cannot put a JDK in it; a push, a schedule or
|
||||
# a manual run, which only a writer can start, may save it. The key names one Temurin build, so the
|
||||
# entry is the same whichever branch saves it. setup-gradle below is stricter (main only), because
|
||||
# a Gradle home differs by branch.
|
||||
# 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.event_name != 'pull_request' }}
|
||||
- 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.event_name == 'pull_request' }}
|
||||
- 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
|
||||
|
||||
Reference in New Issue
Block a user