diff --git a/.github/actions/go-cache/action.sh b/.github/actions/go-cache/action.sh index bd584f6f1..f49d5bb77 100755 --- a/.github/actions/go-cache/action.sh +++ b/.github/actions/go-cache/action.sh @@ -23,8 +23,23 @@ if [ -z "${URL:-}" ]; then exit 0 fi -BIN_PATH="${RUNNER_TEMP:-/tmp}/cigocacher$(go env GOEXE)" -go build -o "${BIN_PATH}" ./cmd/cigocacher +GOPATH=$(command -v go || true) +if [ -z "${GOPATH}" ]; then + if [ ! -f "tool/go" ]; then + echo "Go not available, unable to proceed" + exit 1 + fi + GOPATH="./tool/go" +fi + +BIN_PATH="${RUNNER_TEMP:-/tmp}/cigocacher$(${GOPATH} env GOEXE)" +if [ -d "cmd/cigocacher" ]; then + echo "cmd/cigocacher found locally, building from local source" + "${GOPATH}" build -o "${BIN_PATH}" ./cmd/cigocacher +else + echo "cmd/cigocacher not found locally, fetching from tailscale.com/cmd/cigocacher" + "${GOPATH}" build -o "${BIN_PATH}" tailscale.com/cmd/cigocacher +fi CIGOCACHER_TOKEN="$("${BIN_PATH}" --auth --cigocached-url "${URL}" --cigocached-host "${HOST}" )" if [ -z "${CIGOCACHER_TOKEN:-}" ]; then diff --git a/.github/actions/go-cache/action.yml b/.github/actions/go-cache/action.yml index 38bb15b37..7f5a66de1 100644 --- a/.github/actions/go-cache/action.yml +++ b/.github/actions/go-cache/action.yml @@ -31,4 +31,5 @@ runs: HOST: ${{ inputs.cigocached-host }} CACHE_DIR: ${{ inputs.cache-dir }} working-directory: ${{ inputs.checkout-path }} - run: .github/actions/go-cache/action.sh + # https://github.com/orgs/community/discussions/25910 + run: $GITHUB_ACTION_PATH/action.sh