From 97e8f0e6134408cb76f3e0d24b1d743e9b57923f Mon Sep 17 00:00:00 2001 From: Story Crater Bot <19826264+Riotpiaole@users.noreply.github.com> Date: Sun, 6 Sep 2026 23:33:22 -0700 Subject: [PATCH] fix: validate registry credentials before docker login Add credential validation step to catch missing secrets early with clear error message. Use direct secret injection (not env vars) for better security. Isolate docker config to /tmp/docker-config. --- .gitea/workflows/build-push.yml | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitea/workflows/build-push.yml b/.gitea/workflows/build-push.yml index a981605..46e9147 100644 --- a/.gitea/workflows/build-push.yml +++ b/.gitea/workflows/build-push.yml @@ -1,12 +1,14 @@ -name: Build & Push Portfolio Image +name: CI on: push: - branches: - - main + branches: [main] pull_request: - branches: - - main + branches: [main] + +env: + REGISTRY: forgejo.riotpiao.com + IMAGE: forgejo.riotpiao.com/rock/portfolio jobs: test: @@ -30,9 +32,6 @@ jobs: needs: test if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: node - env: - REGISTRY: forgejo.riotpiao.com - IMAGE: forgejo.riotpiao.com/rock/portfolio steps: - name: Install Node.js and Docker run: | @@ -48,13 +47,21 @@ jobs: SHORT_SHA=$(git rev-parse --short HEAD) echo "short_sha=${SHORT_SHA}" >> $GITHUB_OUTPUT + - name: Validate registry credentials + run: | + if [ -z "${{ secrets.FORGEJO_REGISTRY_USER }}" ] || [ -z "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" ]; then + echo "❌ ERROR: Registry secrets not configured" + echo "Set FORGEJO_REGISTRY_USER and FORGEJO_REGISTRY_TOKEN in repo settings" + exit 1 + fi + echo "✓ Registry credentials configured" + - name: Registry login run: | - echo "${REGISTRY_TOKEN}" | docker login "${REGISTRY}" \ - --username "${REGISTRY_USER}" --password-stdin + echo "${{ secrets.FORGEJO_REGISTRY_TOKEN }}" | docker login "${{ env.REGISTRY }}" \ + --username "${{ secrets.FORGEJO_REGISTRY_USER }}" --password-stdin env: - REGISTRY_USER: ${{ secrets.FORGEJO_REGISTRY_USER }} - REGISTRY_TOKEN: ${{ secrets.FORGEJO_REGISTRY_TOKEN }} + DOCKER_CONFIG: /tmp/docker-config - name: Delete old latest image run: |