Publish image with ko in CI
CI / test (push) Successful in 29s
CI / publish (push) Failing after 57s

This commit is contained in:
Joe Julian
2026-03-28 16:51:50 -07:00
parent b1fc347850
commit 49afad3989
+19 -12
View File
@@ -32,20 +32,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Install Docker and Skopeo
run: |
apt-get update
apt-get install -y docker.io skopeo
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build and Push Image
- name: Configure Registry Auth
env:
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
run: |
local_image="${GITHUB_REPOSITORY##*/}:ci"
archive="/tmp/${GITHUB_REPOSITORY##*/}.tar"
docker build -t "${local_image}" .
docker save "${local_image}" -o "${archive}"
for tag in main "sha-${GITHUB_SHA}"; do
skopeo copy --dest-creds "${GITHUB_REPOSITORY_OWNER}:${REGISTRY_PASSWORD}" --dest-tls-verify=false "docker-archive:${archive}" "docker://${REGISTRY_HOST}/${GITHUB_REPOSITORY}:${tag}"
done
mkdir -p "${HOME}/.docker"
auth="$(printf '%s:%s' "${GITHUB_REPOSITORY_OWNER}" "${REGISTRY_PASSWORD}" | base64 -w0)"
printf '{"auths":{"%s":{"auth":"%s"}}}\n' "${REGISTRY_HOST}" "${auth}" > "${HOME}/.docker/config.json"
chmod 600 "${HOME}/.docker/config.json"
- name: Install ko
run: GOBIN=/usr/local/bin go install github.com/google/ko@v0.18.0
- name: Build and Push Image
env:
REGISTRY_HOST: ${{ vars.REGISTRY_HOST }}
run: |
export KO_DOCKER_REPO="${REGISTRY_HOST}/${GITHUB_REPOSITORY_OWNER}"
ko build --base-import-paths --insecure-registry --sbom=none --tags "main,sha-${GITHUB_SHA}" .