diff --git a/action.yml b/action.yml index 32cdec7..a4789be 100644 --- a/action.yml +++ b/action.yml @@ -69,17 +69,50 @@ runs: sudo apt-get update sudo apt-get install -y --no-install-recommends fonts-noto-cjk + # browser-actions/setup-chrome は RUNNER_TOOL_CACHE 配下にキャッシュする作りだが、 + # GitHub-hosted runner は毎回使い捨て VM なのでジョブをまたいでは残らない。 + # actions/cache で永続化し、2回目以降のダウンロードをスキップする。 + - name: Restore Chrome for Testing cache + id: chrome-cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ${{ runner.tool_cache }}/setup-chrome + key: chromagic-chrome-${{ runner.os }}-${{ runner.arch }} + - name: Setup Chrome for Testing id: chrome uses: browser-actions/setup-chrome@2e1d749697dd1612b833dba4a722266286fbefcd # v2 with: install-dependencies: true + - name: Save Chrome for Testing cache + if: ${{ steps.chrome-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ${{ runner.tool_cache }}/setup-chrome + key: ${{ steps.chrome-cache.outputs.cache-primary-key }} + + # action 自体の node_modules(storycap 等)も package-lock.json のハッシュでキャッシュする。 + - name: Restore action dependencies cache + id: deps-cache + uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ${{ github.action_path }}/node_modules + key: chromagic-deps-${{ runner.os }}-${{ hashFiles(format('{0}/package-lock.json', github.action_path)) }} + - name: Install action dependencies + if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }} shell: bash # consumer 側は実行に要る依存だけ(devDeps=semantic-release 等は入れない)。 run: npm ci --prefix "$GITHUB_ACTION_PATH" --omit=dev --no-audit --no-fund + - name: Save action dependencies cache + if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 + with: + path: ${{ github.action_path }}/node_modules + key: ${{ steps.deps-cache.outputs.cache-primary-key }} + - name: Capture stories (storycap) shell: bash # inputs は run ブロックへ直接展開せず env 経由で渡す(shell/式インジェクション対策)。