ci: restore image publishing with a persistent Docker config
CI / test (push) Successful in 1m38s
CI / chart (push) Successful in 2s
CI / image (push) Failing after 3m29s

A multi-stage kaniko build replaces / with the last stage's root filesystem,
which deletes $HOME/.docker/config.json. Kaniko then resolves credentials at
push time without them, asks the registry for an anonymous token and Gitea
rejects the upload with 401 reqPackageAccess.

Keep the Docker credential store in /kaniko/.docker for the whole image job via
DOCKER_CONFIG and let docker login write there directly. Restore the image job
and document that CI publishes images again.
This commit is contained in:
TapTap committed 2026-11-13 15:51:01 +00:00
1 parent 60e8dadce6
commit a6cc46b747
3 files changed
+61 -11

No files matched your search

+50
View File
@@ -10,6 +10,8 @@ on:
pull_request:
env:
REGISTRY: gitea.tap-tap.win
IMAGE_NAME: taptap/audiomanager
# Built by scripts/build-ci-image.sh from ci/Dockerfile. Bump the tag when
# ci/Dockerfile changes.
CI_IMAGE: gitea.tap-tap.win/taptap/audiomanager-ci:2
@@ -36,3 +38,51 @@ jobs:
run: |
helm lint charts/musicmanager
helm template musicmanager charts/musicmanager --set users.existingSecret=test > /dev/null
image:
needs:
- test
- chart
if: github.event_name == 'push'
runs-on: ubuntu-latest
container:
image: gitea.tap-tap.win/taptap/audiomanager-ci:2
permissions:
contents: read
packages: write
env:
# A multi-stage build replaces / with the last stage's root filesystem,
# which deletes $HOME/.docker/config.json. Kaniko then has no credentials
# left for the push and gets an anonymous registry token (Gitea reports
# this as "401 reqPackageAccess"). /kaniko is preserved by kaniko, so
# keep the Docker credential store there for the whole job.
DOCKER_CONFIG: /kaniko/.docker
steps:
- uses: actions/checkout@v4
- name: Log in to the registry
run: |
mkdir -p "$DOCKER_CONFIG"
echo "${{ secrets.AUDIOMANAGER_REGISTRY_TOKEN }}" \
| docker login "$REGISTRY" \
--username "${{ gitea.actor }}" \
--password-stdin
- name: Build and push
run: |
set -euo pipefail
tags=("$REGISTRY/$IMAGE_NAME:sha-${GITHUB_SHA::7}")
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
tags+=("$REGISTRY/$IMAGE_NAME:${GITHUB_REF_NAME}")
else
tags+=("$REGISTRY/$IMAGE_NAME:latest")
fi
destinations=()
for tag in "${tags[@]}"; do
destinations+=(--destination "$tag")
done
kaniko-executor \
--context="dir://$PWD" \
--dockerfile="$PWD/Dockerfile" \
--snapshot-mode=redo \
"${destinations[@]}"