Compare commits

..

1 Commits

Author SHA1 Message Date
Tommy Malmqvist
0147fa5df8
Merge f20f287d5b into 4532346e13 2025-09-17 08:17:03 +00:00

View File

@ -26,55 +26,26 @@ inputs:
runs: runs:
using: "composite" using: "composite"
steps: steps:
- id: pull-with-credentials - id: login
name: Pull image using provided credentials name: Login to registry (if credentials provided)
if: ${{ inputs.registry_username && inputs.registry_password && inputs.registry }} if: ${{ inputs.registry_username && inputs.registry_password && inputs.registry }}
shell: bash shell: bash
env: env:
IMAGE_INPUT: ${{ inputs.image }}
REGISTRY: ${{ inputs.registry }} REGISTRY: ${{ inputs.registry }}
REG_USER: ${{ inputs.registry_username }} REG_USER: ${{ inputs.registry_username }}
REG_PASS: ${{ inputs.registry_password }} REG_PASS: ${{ inputs.registry_password }}
run: | run: |
set -euo pipefail set -euo pipefail
IMAGE="$IMAGE_INPUT" if [ -z "$REGISTRY" ] || [ -z "$REG_USER" ] || [ -z "$REG_PASS" ]; then
if [ -n "$REGISTRY" ]; then echo "Missing registry or credentials; skipping login"
REG="${REGISTRY%/}" exit 0
IMAGE="$REG/$IMAGE"
fi fi
echo "Using image: $IMAGE" # Mask sensitive values
echo "Credentials provided; attempting docker login to $REGISTRY"
if [ -n "$REG_PASS" ]; then if [ -n "$REG_PASS" ]; then
echo "::add-mask::$REG_PASS" echo "::add-mask::$REG_PASS"
fi fi
echo "Logging into registry: $REGISTRY"
echo "$REG_PASS" | docker login "$REGISTRY" --username "$REG_USER" --password-stdin echo "$REG_PASS" | docker login "$REGISTRY" --username "$REG_USER" --password-stdin
if docker pull "$IMAGE" >/dev/null 2>&1; then
echo "Image pulled successfully after login."
else
echo "Failed to pull image after login; proceeding to run (docker run may fail)."
fi
- id: pull-anonymous
name: Pull image anonymously
if: ${{ !(inputs.registry_username && inputs.registry_password && inputs.registry) }}
shell: bash
env:
IMAGE_INPUT: ${{ inputs.image }}
REGISTRY: ${{ inputs.registry }}
run: |
set -euo pipefail
IMAGE="$IMAGE_INPUT"
if [ -n "$REGISTRY" ]; then
REG="${REGISTRY%/}"
IMAGE="$REG/$IMAGE"
fi
echo "Using image: $IMAGE"
echo "No credentials provided (or registry not set); attempting anonymous pull"
if docker pull "$IMAGE" >/dev/null 2>&1; then
echo "Anonymous pull succeeded."
else
echo "Anonymous pull failed; proceeding to run (docker run may fail if auth required)."
fi
- id: run - id: run
name: Run yq container name: Run yq container