fix: use ghcr

This commit is contained in:
iceBear67
2026-07-15 17:19:32 +08:00
parent 871117bb3b
commit 3a5ad7e318
+13 -22
View File
@@ -1,7 +1,7 @@
name: publish-client-image name: publish-client-image
# Builds the redapricot Go client into a container image with ko and pushes it # Builds the redapricot Go client into a container image with ko and pushes it to
# to the configured registry. Triggers on version tags and manual dispatch. # the GitHub Container Registry (ghcr.io). Triggers on version tags and manual dispatch.
on: on:
push: push:
tags: tags:
@@ -15,17 +15,11 @@ on:
permissions: permissions:
contents: read contents: read
packages: write # required only when KO_DOCKER_REPO is on ghcr.io packages: write # lets the built-in GITHUB_TOKEN push packages to ghcr.io
env: env:
# ───────────────────────────────────────────────────────────────────────────── # Image repository on ghcr.io: ghcr.io/<owner>/<name> (must be lowercase).
# EDIT ME — the image repository to publish to: <registry>/<namespace>/<name> KO_DOCKER_REPO: ghcr.io/saltedfishclub/redapricot-client
# examples:
# ghcr.io/your-org/redapricot-client
# docker.io/youruser/redapricot-client
# registry.example.com/team/redapricot-client
# ─────────────────────────────────────────────────────────────────────────────
KO_DOCKER_REPO: git.sfclub.cc/cloud/redapricot-client
jobs: jobs:
publish: publish:
@@ -40,27 +34,24 @@ jobs:
- uses: ko-build/setup-ko@v0.9 - uses: ko-build/setup-ko@v0.9
- name: Derive registry host and image tags - name: Derive image tags
id: meta id: meta
run: | run: |
echo "registry=${KO_DOCKER_REPO%%/*}" >> "$GITHUB_OUTPUT"
tags="${GITHUB_REF_NAME},sha-${GITHUB_SHA::7}" tags="${GITHUB_REF_NAME},sha-${GITHUB_SHA::7}"
if [ -n "${{ github.event.inputs.tag }}" ]; then if [ -n "${{ github.event.inputs.tag }}" ]; then
tags="${tags},${{ github.event.inputs.tag }}" tags="${tags},${{ github.event.inputs.tag }}"
fi fi
echo "tags=${tags}" >> "$GITHUB_OUTPUT" echo "tags=${tags}" >> "$GITHUB_OUTPUT"
# Authenticate to the registry. # Authenticate to ghcr.io with the workflow's built-in GITHUB_TOKEN — no repo
# • ghcr.io: setup-ko already logs in with the built-in GITHUB_TOKEN, so you # secrets needed. ko reads the Docker credentials this step writes, so it
# may delete this step. # pushes as the same authenticated user.
# • any other registry: set the REGISTRY_USERNAME / REGISTRY_PASSWORD repo - name: Log in to ghcr.io
# secrets; the host is derived from KO_DOCKER_REPO above.
- name: Log in to the container registry
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: ${{ steps.meta.outputs.registry }} registry: ghcr.io
username: ${{ secrets.REGISTRY_USERNAME }} username: ${{ github.actor }}
password: ${{ secrets.REGISTRY_PASSWORD }} password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image with ko - name: Build and push image with ko
run: | run: |