refactor: enhance Gitea registry login with fallback credentials and error handling
This commit is contained in:
@@ -41,8 +41,29 @@ jobs:
|
|||||||
|
|
||||||
- name: Log in to Gitea Container Registry
|
- name: Log in to Gitea Container Registry
|
||||||
shell: sh
|
shell: sh
|
||||||
|
env:
|
||||||
|
REGISTRY_USERNAME: ${{ secrets.GITEA_REGISTRY_USERNAME }}
|
||||||
|
REGISTRY_TOKEN: ${{ secrets.GITEA_REGISTRY_TOKEN }}
|
||||||
|
LEGACY_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
ACTOR_USERNAME: ${{ github.actor }}
|
||||||
run: |
|
run: |
|
||||||
echo "${{ secrets.GITEA_TOKEN }}" | docker login "${{ steps.meta.outputs.registry_host }}" -u "${{ github.actor }}" --password-stdin
|
USERNAME="$REGISTRY_USERNAME"
|
||||||
|
TOKEN="$REGISTRY_TOKEN"
|
||||||
|
|
||||||
|
if [ -z "$USERNAME" ]; then
|
||||||
|
USERNAME="$ACTOR_USERNAME"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TOKEN" ]; then
|
||||||
|
TOKEN="$LEGACY_TOKEN"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$USERNAME" ] || [ -z "$TOKEN" ]; then
|
||||||
|
echo "Registry login failed: set GITEA_REGISTRY_USERNAME and GITEA_REGISTRY_TOKEN (or fallback GITEA_TOKEN)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$TOKEN" | docker login "${{ steps.meta.outputs.registry_host }}" -u "$USERNAME" --password-stdin
|
||||||
|
|
||||||
- name: Build and push image
|
- name: Build and push image
|
||||||
shell: sh
|
shell: sh
|
||||||
|
|||||||
Reference in New Issue
Block a user