From 6413dba3ec2a1e09737ce7023968f263547afb0d Mon Sep 17 00:00:00 2001 From: Robear Selwans Date: Sat, 2 May 2026 18:03:22 +0300 Subject: [PATCH] Default registry username to Gitea actor --- .gitea/workflows/build-ci-image.yml | 14 +++++++++++++- ci/README.md | 11 +++++++++-- ci/USE_CI_IMAGE.md | 21 +++++++++++---------- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/.gitea/workflows/build-ci-image.yml b/.gitea/workflows/build-ci-image.yml index 962f11d..e79e2d7 100644 --- a/.gitea/workflows/build-ci-image.yml +++ b/.gitea/workflows/build-ci-image.yml @@ -11,6 +11,8 @@ on: env: REGISTRY_HOST: git.neosisyphus.com REGISTRY_IMAGE: git.neosisyphus.com/evol3d/evol-testbed + # Optional. If this secret is not set, the workflow uses GITHUB_ACTOR. + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} jobs: image: @@ -21,8 +23,18 @@ jobs: - name: Log in to container registry run: | + set -eu + username="${REGISTRY_USERNAME:-${GITHUB_ACTOR:-}}" + if [ -z "$username" ]; then + echo "REGISTRY_USERNAME secret is empty and GITHUB_ACTOR is not set" >&2 + exit 1 + fi + if [ -z "${{ secrets.REGISTRY_PASSWORD }}" ]; then + echo "REGISTRY_PASSWORD secret is empty. Set it to a Gitea access token with package write permission." >&2 + exit 1 + fi echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login "$REGISTRY_HOST" \ - -u "${{ secrets.REGISTRY_USERNAME }}" \ + -u "$username" \ --password-stdin - name: Build CI image diff --git a/ci/README.md b/ci/README.md index 590c1a4..594bb8a 100644 --- a/ci/README.md +++ b/ci/README.md @@ -35,15 +35,22 @@ REGISTRY_IMAGE=git.neosisyphus.com/evol3d/evol-testbed CI_IMAGE=git.neosisyphus.com/evol3d/evol-testbed ``` -Add these **Actions secrets**: +Add this **Actions secret**: ```text -REGISTRY_USERNAME=your-gitea-username REGISTRY_PASSWORD=your-gitea-token-or-password ``` The token/password needs permission to publish packages/container images. +Optional: add this secret if your registry username is different from the Gitea Actions actor: + +```text +REGISTRY_USERNAME=your-gitea-username +``` + +If `REGISTRY_USERNAME` is not set, the workflow uses `$GITHUB_ACTOR`. + ## Build manually ```bash diff --git a/ci/USE_CI_IMAGE.md b/ci/USE_CI_IMAGE.md index 35e71af..da5628e 100644 --- a/ci/USE_CI_IMAGE.md +++ b/ci/USE_CI_IMAGE.md @@ -169,24 +169,28 @@ In your repository: 1. Go to **Settings**. 2. Go to **Actions**. 3. Go to **Secrets**. -4. Add: +4. Add this required secret: ```text -REGISTRY_USERNAME REGISTRY_PASSWORD ``` Example: ```text -REGISTRY_USERNAME=myusername REGISTRY_PASSWORD= ``` -Use your Gitea username for `REGISTRY_USERNAME`. - Use the token from step 3 for `REGISTRY_PASSWORD`. +Optional: add this secret if your registry username is different from the Gitea Actions actor: + +```text +REGISTRY_USERNAME=myusername +``` + +If `REGISTRY_USERNAME` is not set, the workflow uses `$GITHUB_ACTOR`. + --- ## 6. Check the image build workflow @@ -592,13 +596,10 @@ This avoids surprise breakage when `clang22` or `latest` changes. ```text 1. Commit ci/Dockerfile and workflows. 2. Create Gitea token with package/container write access. -3. Add Actions variables: - - REGISTRY_HOST - - REGISTRY_IMAGE - - CI_IMAGE +3. Registry/image values are already hardcoded in the workflow. 4. Add Actions secrets: - - REGISTRY_USERNAME - REGISTRY_PASSWORD + - REGISTRY_USERNAME only if needed 5. Make sure the runner can run docker build. 6. Run build-ci-image workflow. 7. Confirm image appears in Gitea Packages.