use variables for setting path: key when using actions/cache ?
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 5.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
i'm attempting to cache the homebrew packages for my repo using the actions/cache github action in my workflow file. i use different runners for my project, ie. the arm64 macos runner, and the legacy amd64 / intel macos runners. with homebrew installed on macos arm, the default prefix ie. $(brew --prefix) is /opt/homebrew whereas on intel macs, the default homebrew prefix is /usr/local
i attempted to use the below step in my workflow file to setup some vars to be used throughout my workflow however i don't think this action actions/cache supports using variables stored in the GITHUB_ENV from what i have been trying.
- name: set brew prefix & cache paths
id: set-brew-prefix-and-cache-paths
run: |
bp=$(brew --prefix)
hbc="$bp/cache"
echo "bp=\"$bp\"" >> "$GITHUB_OUTPUT"
echo "hbc=\"$hbc\"" >> "$GITHUB_OUTPUT"
echo "bp=\"$bp\"" >> "$GITHUB_ENV"
echo "hbc=\"$hbc\"" >> "$GITHUB_ENV"
- name: save homebrew install
uses: actions/cache@v2
env:
bp: ${{ steps.set-brew-prefix-and-cache-paths.outputs.bp }}
with:
#----
# NO WORK!
# path: $(brew --prefix)
#----
# NO WORK!
path: $bp
#----
# NO WORK!
# path: ${{ env.bp }} # does not properly save /opt/homebrew on macos arm64
#----
# key: ${{ env.cache-key }}
# key: ${{ env.envHash }}-freecad-deps-${{ runner.os }}-brew
# key: homebrew-packages-${{ runner.os }}-${{ github.run_id }}
# key: ${{ steps.cache-brewdeps-restore.outputs.cache-primary-key }}
key: ${{ runner.os }}-brewdeps
the only way i've been able to properly save a cache is to use a literal path ie. /opt/homebrew
does this action not support the use of variables when setting the path: key?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the workflow step shown in the report, especially the actions/cache@v2 path input and the set-brew-prefix-and-cache-paths outputs and GITHUB_ENV writes. Compare how those values are consumed on ARM64 and Intel macOS runners; done means establishing whether variable-based paths are supported and documenting the resulting behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100