코딩과로그

[TIL] 깃허브 캐시값 얻어오기 링크 본문

기타1/깃헙 액션

[TIL] 깃허브 캐시값 얻어오기 링크

피리음 2023. 5. 1. 05:54

WorkFlows 진행 시 빈번히 설치하는 의존 Library들이 있는데 매번 workflows를 실행할 때마다 Library를 설치하면 시간소요가 많이 된다.
github에서 지원하는 Cache를 사용하면 의존 library를 한번 설치한 다음부터는 Workflows에는 설치했던 라이브버리를 이전보다 빠르게 가져올 수 있도록 할 수 있다.

예제:
workflows

name: cacheing-dependency
run-name: cacheing-dependency 🚀
# Event
on: [workflow_dispatch]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - name: Get code
        uses: actions/checkout@v3

      - name: Cache node modules
        id: cache-npm
        uses: actions/cache@v3
        env:
          cache-name: cache-node-modules
        with:
          # npm cache files are stored in `~/.npm` on Linux/macOS
          path: ~/.npm
          key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}

      - name: Install dependencies
        run: |
          cd react-sample
          npm ci

reference:
github 공식 문서

https://www.daleseo.com/github-actions-cache/