Skip to content

Commit 36bbb4c

Browse files
authored
fix: use custom step for docker-credential-gcr (#996)
* Use custom step for docker-credentual-gcr Replacing the upstream action so we can install the binary for different architectures, as well as removing sudo from the untar process * Prettier
1 parent d99f255 commit 36bbb4c

File tree

1 file changed

+47
-5
lines changed

1 file changed

+47
-5
lines changed

actions/login-to-gar/action.yaml

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,53 @@ runs:
5959
with:
6060
project_id: "grafanalabs-workload-identity"
6161
workload_identity_provider: "projects/304398677251/locations/global/workloadIdentityPools/github/providers/github-provider"
62-
- name: Setup docker-credential-gcr
63-
if: ${{ steps.auth_with_service_account.outputs.access_token == '' }}
64-
uses: StevenACoffman/setup-docker-credential-gcr@a8f1898ecad516cb17f55ebd1dd2583abc584352 # v0.0.3
65-
with:
66-
version: v2.1.28
62+
63+
- name: Install docker-credential-gcr
64+
shell: bash
65+
env:
66+
DOCKER_CREDENTIAL_GCR_VERSION: "v2.1.28"
67+
run: |
68+
set -ex
69+
70+
# Install docker-credential-gcr:
71+
# - if version is "tip", install from tip of main.
72+
# - if version is "latest-release", look up latest release.
73+
# - otherwise, install the specified version.
74+
case "${DOCKER_CREDENTIAL_GCR_VERSION}" in
75+
tip)
76+
echo "Installing docker-credential-gcr using go install"
77+
go install github.com/GoogleCloudPlatform/docker-credential-gcr@main
78+
;;
79+
latest-release)
80+
tag=$(curl -L -s -u "username:${{ github.token }}" https://api.github.com/repos/GoogleCloudPlatform/docker-credential-gcr/releases/latest | jq -r '.tag_name')
81+
;;
82+
*)
83+
tag="${DOCKER_CREDENTIAL_GCR_VERSION}"
84+
esac
85+
86+
# Normalize OS name
87+
os="${{ runner.os }}"
88+
case "$os" in
89+
macOS) os="darwin" ;;
90+
Linux) os="linux" ;;
91+
Windows) os="windows" ;;
92+
*) echo "Unknown OS: $os"; exit 1 ;;
93+
esac
94+
95+
# Map runner.arch to release asset arch
96+
arch="${{ runner.arch }}"
97+
case "$arch" in
98+
X64) arch="amd64" ;;
99+
ARM64) arch="arm64" ;;
100+
*) echo "Unsupported arch: $arch"; exit 1 ;;
101+
esac
102+
103+
if [[ ! -z ${tag} ]]; then
104+
echo "Installing docker-credential-gcr @ ${tag} for ${os}/${arch}"
105+
mkdir -p /opt/docker-credential-gcr
106+
curl -fsL "https://github.com/GoogleCloudPlatform/docker-credential-gcr/releases/download/${tag}/docker-credential-gcr_${os}_${arch}-${tag:1}.tar.gz" | tar xzf - -C /opt/docker-credential-gcr docker-credential-gcr
107+
echo "/opt/docker-credential-gcr" >> $GITHUB_PATH
108+
fi
67109
- name: "Configure GCP Artifact Registry"
68110
if: ${{ steps.auth_with_service_account.outputs.access_token == '' }}
69111
id: configure-docker

0 commit comments

Comments
 (0)