Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use variables for setting path: key when using actions/cache ? #1425

Open
ipatch opened this issue Jun 25, 2024 · 0 comments
Open

use variables for setting path: key when using actions/cache ? #1425

ipatch opened this issue Jun 25, 2024 · 0 comments

Comments

@ipatch
Copy link

ipatch commented Jun 25, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant