From aca56e7ad96692161f3cd27c27f185880fc77720 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 21 Jun 2026 01:27:21 -0400 Subject: [PATCH] Make Docker build/push resilient to missing secrets for local act runs - Add credential-check step so docker login gracefully skips when GITEA_TOKEN is unavailable (e.g. local 'act' runs) - Build step always runs locally; push only when credentials exist - Add .actrc for convenience runner image mapping --- .actrc | 2 ++ .gitea/workflows/build-and-deploy.yml | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 .actrc diff --git a/.actrc b/.actrc new file mode 100644 index 0000000..6eb74fe --- /dev/null +++ b/.actrc @@ -0,0 +1,2 @@ +-P ubuntu-latest=catthehacker/ubuntu:act-latest +--artifact-server-path=/tmp/act-artifacts diff --git a/.gitea/workflows/build-and-deploy.yml b/.gitea/workflows/build-and-deploy.yml index 1726364..68b2dd3 100644 --- a/.gitea/workflows/build-and-deploy.yml +++ b/.gitea/workflows/build-and-deploy.yml @@ -42,12 +42,23 @@ jobs: echo "full=${REGISTRY_HOST}/${REPO}:${TAG}" >> "$GITHUB_OUTPUT" echo "latest=${REGISTRY_HOST}/${REPO}:latest" >> "$GITHUB_OUTPUT" + - name: Check Docker registry credentials + id: registry-check + run: | + if [ -n "${{ secrets.GITEA_TOKEN }}" ]; then + echo "available=true" >> "$GITHUB_OUTPUT" + else + echo "available=false" >> "$GITHUB_OUTPUT" + fi + - name: Install Docker CLI + if: steps.registry-check.outputs.available == 'true' run: | apt-get update -qq apt-get install -y -qq docker.io - name: Log in to Gitea Container Registry + if: steps.registry-check.outputs.available == 'true' run: | echo "${{ secrets.GITEA_TOKEN }}" | \ docker login "$REGISTRY_HOST" \ @@ -59,7 +70,7 @@ jobs: with: context: . file: ${{ env.DOCKERFILE_PATH }} - push: true + push: ${{ steps.registry-check.outputs.available == 'true' }} tags: | ${{ steps.image-meta.outputs.full }} ${{ steps.image-meta.outputs.latest }}