Skip to content

GitHub:Actions:actions/cache

Cache dependencies and build outputs in GitHub Actions

hashFiles

Example with a single pattern

Matches any package-lock.json file in the repository.

hashFiles('**/package-lock.json')

Example with multiple patterns

Creates a hash for any package-lock.json and Gemfile.lock files in the repository.

hashFiles('**/package-lock.json', '**/Gemfile.lock')

Matching a cache key

restore-keys에 캐시 누락이 있을 때 사용할 대체 복원 키 목록을 지정할 수 있습니다. 가장 구체적인 것부터 가장 덜 구체적인 것 순으로 여러 복원 키를 생성할 수 있습니다. 작업 은 순차적으로 검색합니다. restore-keys키가 직접 일치하지 않으면 작업은 복원 키가 접두사로 붙은 키를 검색합니다. 복원 키에 대한 부분 일치 항목이 여러 개 있는 경우 이 작업은 가장 최근에 생성된 캐시를 반환합니다.

Example

restore-keys: |
  npm-feature-${{ hashFiles('package-lock.json') }}
  npm-feature-
  npm-

러너는 표현식을 평가하여 다음과 같이 확인합니다.

restore-keys: |
  npm-feature-d5ea0750
  npm-feature-
  npm-

복원 키 npm-feature-는 동일 문자열로 시작하는 모든 키와 일치합니다. 예를 들어 두 키 모두 복원 키 npm-feature-fd3052denpm-feature-a9b253ff 일치합니다. 생성 날짜가 가장 최근인 캐시가 사용됩니다.

이 예제의 키는 다음 순서로 검색됩니다.

  • npm-feature-d5ea0750 특정 해시와 일치합니다.
  • npm-feature- 접두사가 붙은 캐시 키와 일치합니다.
  • npm- 접두사가 붙은 모든 키와 일치합니다.

See also

Favorite site