From 72786d44d0d9e03cc0af768efe3580f874aad221 Mon Sep 17 00:00:00 2001 From: "A.J. Stein" Date: Thu, 28 Sep 2023 12:44:18 -0400 Subject: [PATCH] Check for cache and restore of branches on #19. 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. --- .github/workflows/pages.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml index 2cb5a1329..7f1e4946a 100644 --- a/.github/workflows/pages.yaml +++ b/.github/workflows/pages.yaml @@ -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 @@ -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 }}