Skip to content

Commit

Permalink
Check for cache and restore of branches on #19.
Browse files Browse the repository at this point in the history
When testing on my fork, I had forgotten my fork did not have any of the
prototype branches and for the use case of using GHA on the upstream,
we only check "origin" (the one remote) for now, but that was not as
intended during test that must happen off fork. This testing reminded me
that caching should use the branches as an output and only restore from
cache if they are defined, especially if the default prototype prefix is
used, but nothing is returned, so don't cache empty.
  • Loading branch information
aj-stein-nist committed Sep 28, 2023
1 parent ea8394e commit 72786d4
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ jobs:
prefix="${{ format('{0}', github.event.inputs.prefix) || 'prototype' }}"
branches=$(cd "${OSCAL_DIR}"; git ls-remote origin "${prefix}*" | sed -n -e "s|^.*\(refs/heads/\)\(${prefix}\)|\2|p")
# Wildcards after a stable tag prefix like v* for v1.0.0 will not work, so generate outputs for content and data paths for next step
echo branches="${branches}" >> $GITHUB_OUTPUT
echo content_paths=$(printf "site/content/models/%s/\n" $branches) >> $GITHUB_OUTPUT
echo data_paths=$(printf "site/content/data/%s/\n" $branches) >> $GITHUB_OUTPUT
# Prototype branch content may change so hash branch name and current commit hash for its HEAD as restore key part
Expand All @@ -98,6 +99,7 @@ jobs:
cache-models-${{ hashFiles('site/archetypes/**') }}-${{ hashFiles('support/*.sh') }}
- name: Cache generated content for existing prototype-branches
uses: actions/cache@v3
if: steps.get-prototype-branches.outputs.branches != ''
with:
path: |
${{ steps.get-prototype-branches.outputs.content_paths }}
Expand Down

0 comments on commit 72786d4

Please sign in to comment.