Open
Description
Version
actions/setup-go@v2
Description
In some of our GitHub Actions workflows, we opt to cache the GOCACHE
between jobs to save compilation time. It seems like we currently need to run go env GOCACHE
to fetch the correct GOCACHE
path after this action is run, e.g.
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.14"
- name: go env
run: |
echo "::set-env name=GOCACHE::$(go env GOCACHE)"
- uses: actions/cache@v2
with:
path: ${{ env.GOCACHE }}
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}
Since this action already runs go env
, it would be great if those values were either available as outputs, e.g.
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
id: setup_go
with:
go-version: "1.14"
- uses: actions/cache@v2
with:
path: ${{ steps.setup_go.outputs.GOCACHE }}
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}
Or if we could configure environment variables to automatically be exported:
jobs:
example:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.14"
export-environment-variables: [GOCACHE]
- uses: actions/cache@v2
with:
path: ${{ env.GOCACHE }}
key: ${{ runner.os }}-GOCACHE-${{ hashFiles('go.sum') }}-${{ hashFiles('src/**') }}
Thank you for the consideration! Please reach out if I'm missing something and this is already possible or if this would be acceptable as an enhancement.
Activity
Sergey-Murtazin commentedon Oct 19, 2021
Hi @bflad ! Sorry for the late response!
Could you please clarify if the issue is still actual for you?
Thanks!
jgustie commentedon Oct 19, 2021
It definitely helps make workflow definitions platform agnostic. For example, it would allow all three platform specific cache action examples to be replaced with a single more robust example:
This particular use case may not be as relevant if
setup-go
had acache
input (likesetup-node
) to handle cache setup.bflad commentedon Oct 19, 2021
Hi @Sergey-Murtazin 👋 Certainly still valid for our use cases, mostly to help with platform agnostic workflows as mentioned above. Thanks!
lucacome commentedon Jul 23, 2022
I was about to open a similar issue 🙂
I'm interested in
GOPATH
and I know it's pretty simple to retrieve it, but having it as an output of the action would make the workflows cleaner IMHO.A JSON output of
go env
would work too.qrkourier commentedon Feb 15, 2023
It'd be helpful to have
go env
as outputs from this action so that it's not necessary to solve for GOBIN, GOPATH, GOCACHE in the worflow.go env
and some env as strings #334lucacome commentedon Feb 16, 2023
I've opened a #334 with some default outputs that I think will cover 99% of the cases, let me know what you think 🙏
urica12 commentedon Feb 16, 2023
Run
mvdan commentedon Mar 27, 2023
Would love this as well. I currently have extra steps like
echo "dir=$(go env GOMODCACHE)" >> ${GITHUB_OUTPUT}
, which are verbose and wasteful, since setup-go has already rungo env
.9 remaining items