3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2026-08-07 20:11:11 +00:00
cache/checkout/action.yml
Jasperhino 01f9143258 checkout: unify cache on repo-<sha>, drop sparse/depth/filter inputs
Breaking: removes fetch-depth, filter, sparse-checkout, sparse-checkout-cone-mode
inputs. Composite always populates full history + blob:none so every caller
for the same SHA gets the same tarball. Cache key simplifies to repo-<sha>.

Rationale: every sparse callsite in cula-platform runs downstream of a
full-tree-populating job (find_affected). Full-tree restore (~3-5s) is
faster than sparse clone (~10-20s). One cache entry per SHA, no
fragmentation, no races on conflicting tarball contents.

If someone needs a sparse checkout outside the cache, use raw actions/checkout.
2026-04-24 11:27:55 +02:00

57 lines
2.3 KiB
YAML

name: 'Checkout (GCS-cached)'
description: "Restore the repo working tree from GCS keyed on commit SHA, falling back to actions/checkout on miss. Always populates with full history + blob:none so every downstream job in the same run gets the same tarball regardless of its stated depth/filter needs."
inputs:
ref:
description: 'Branch, tag or SHA to check out on cache miss. Defaults to the workflow ref.'
required: false
default: ''
gcs-bucket:
description: 'GCS bucket holding the cached working trees. When empty, cache is bypassed and this step is a plain actions/checkout.'
required: false
default: 'cula-warpbuild-ci-cache-ew1'
gcs-path-prefix:
description: 'Path prefix inside the bucket.'
required: false
default: 'github-checkout'
outputs:
cache-hit:
description: 'true when the working tree was restored from GCS.'
value: ${{ steps.restore.outputs.cache-hit }}
runs:
using: composite
steps:
- name: Restore working tree from GCS
id: restore
if: inputs.gcs-bucket != ''
uses: Cula-Technologies/cache/restore@v1
with:
path: .
key: repo-${{ github.sha }}
gcs-bucket: ${{ inputs.gcs-bucket }}
gcs-path-prefix: ${{ inputs.gcs-path-prefix }}
- name: Fresh checkout (cache miss)
if: steps.restore.outputs.cache-hit != 'true'
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
filter: blob:none
ref: ${{ inputs.ref }}
- name: Strip credentials before caching
if: inputs.gcs-bucket != '' && steps.restore.outputs.cache-hit != 'true'
shell: sh
run: |
# actions/checkout writes a token-bearing extraheader into .git/config; remove it
# so the cached tarball doesn't carry credentials across jobs. Use sh instead of
# bash so the step works in minimal container images (e.g. jest-runtime).
git -C "${GITHUB_WORKSPACE}" config --local --unset-all http.https://github.com/.extraheader || true
- name: Save working tree to GCS
if: inputs.gcs-bucket != '' && steps.restore.outputs.cache-hit != 'true'
uses: Cula-Technologies/cache/save@v1
with:
path: .
key: repo-${{ github.sha }}
gcs-bucket: ${{ inputs.gcs-bucket }}
gcs-path-prefix: ${{ inputs.gcs-path-prefix }}