Some checks failed
Test Deploy to OCI Registry / deploy (push) Failing after 3m34s
143 lines
4.3 KiB
YAML
143 lines
4.3 KiB
YAML
name: 'Deploy to OCI Registry'
|
|
description: 'Build and push a Docker image to an OCI Registry'
|
|
inputs:
|
|
registry-url:
|
|
description: 'OCI Registry URL'
|
|
required: true
|
|
registry-token:
|
|
description: 'OCI Registry Token'
|
|
required: true
|
|
architectures:
|
|
description: 'Architectures to build for'
|
|
required: true
|
|
default: 'amd64,arm64'
|
|
tags:
|
|
description: 'Tags to apply to the image'
|
|
required: true
|
|
default: 'latest'
|
|
name:
|
|
description: 'Name of the image'
|
|
required: true
|
|
default: "auto"
|
|
dockerfile:
|
|
description: 'Path to the Dockerfile'
|
|
required: true
|
|
default: './Dockerfile'
|
|
owner:
|
|
description: 'OCI Registry owner'
|
|
required: true
|
|
default: ${{ github.repository_owner }}
|
|
env:
|
|
VALID_ARCHITECTURES: 'amd64,arm64'
|
|
runs:
|
|
using: "composite"
|
|
steps:
|
|
- name: Set up QEMU
|
|
uses: docker/setup-qemu-action@v2
|
|
|
|
- name: Install Docker
|
|
id: install-docker-quick
|
|
shell: bash
|
|
run: |
|
|
echo "🐋 Installing Docker..."
|
|
curl -fsSL https://get.docker.com | sh
|
|
echo "✅ Docker installed"
|
|
docker --version
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
id: setup-buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Validating Inputs
|
|
shell: bash
|
|
id: validate-inputs
|
|
env:
|
|
VALID_ARCHITECTURES: ${{ env.VALID_ARCHITECTURES }}
|
|
TAGS: ${{ inputs.tags }}
|
|
ARCHITECTURES: ${{ inputs.architectures }}
|
|
NAME: ${{ inputs.name }}
|
|
REGISTRY_URL: ${{ inputs.registry-url }}
|
|
REGISTRY_OWNER: ${{ inputs.owner }}
|
|
DOCKERFILE: ${{ inputs.dockerfile }}
|
|
run: |
|
|
bash ./scripts/validate_input.sh
|
|
|
|
- name: Summary of Inputs
|
|
shell: bash
|
|
id: summary
|
|
env:
|
|
NAME: ${{ inputs.name }}
|
|
REGISTRY_URL: ${{ inputs.registry-url }}
|
|
REGISTRY_OWNER: ${{ inputs.owner }}
|
|
ARCHITECTURES: ${{ inputs.architectures }}
|
|
TAGS: ${{ inputs.tags }}
|
|
DOCKERFILE: ${{ inputs.dockerfile }}
|
|
run: |
|
|
echo "📦 Building image for: $NAME"
|
|
echo "🔗 Registry URL: $REGISTRY_URL"
|
|
echo "🔑 Registry Owner: $REGISTRY_OWNER"
|
|
echo "🏗️ Architectures: $ARCHITECTURES"
|
|
echo "🏷️ Tags: $TAGS"
|
|
echo "📄 Dockerfile: $DOCKERFILE"
|
|
|
|
- name: Authenticate with OCI Registry
|
|
id: login
|
|
shell: bash
|
|
env:
|
|
REGISTRY_URL: ${{ inputs.registry-url }}
|
|
REGISTRY_OWNER: ${{ inputs.owner }}
|
|
REGISTRY_TOKEN: ${{ inputs.registry-token }}
|
|
run: |
|
|
echo "🐋 Logging on to OCI Registry..."
|
|
echo "$REGISTRY_TOKEN" | docker login "$REGISTRY_URL" -u "$REGISTRY_OWNER" --password-stdin
|
|
if [ $? -ne 0 ]; then
|
|
echo "❌ Failed to authenticate with OCI Registry"
|
|
exit 1
|
|
fi
|
|
echo "✅ Authenticated with OCI Registry"
|
|
|
|
- name: Build and push OCI Image
|
|
id: build
|
|
shell: bash
|
|
env:
|
|
ARCHITECTURES: ${{ inputs.architectures }}
|
|
TAGS: ${{ inputs.tags }}
|
|
NAME: ${{ inputs.name }}
|
|
REGISTRY_URL: ${{ inputs.registry-url }}
|
|
DOCKERFILE: ${{ inputs.dockerfile }}
|
|
REPOSITORY_NAME: ${{ github.repository }}
|
|
run: |
|
|
# Determine image name if set to auto
|
|
if [ "$NAME" == "auto" ]; then
|
|
echo "🔍 Auto-detecting image name..."
|
|
NAME=$(echo "$REPOSITORY_NAME" | tr '[:upper:]' '[:lower:]')
|
|
echo "🔍 Auto-detected image name: $NAME"
|
|
fi
|
|
|
|
# Process tags into an array and build tag arguments
|
|
IFS=',' read -r -a TAG_ARRAY <<< "$TAGS"
|
|
TAG_ARGS=""
|
|
for TAG in "${TAG_ARRAY[@]}"; do
|
|
TAG_ARGS+=" --tag $REGISTRY_URL/$NAME:$TAG"
|
|
done
|
|
|
|
echo "🔨 Building Docker image: $NAME"
|
|
docker buildx build \
|
|
--platform "$ARCHITECTURES" \
|
|
$TAG_ARGS \
|
|
--file "$DOCKERFILE" \
|
|
--push \
|
|
.
|
|
echo "🔨 Docker image built and pushed."
|
|
|
|
# Verify each tag
|
|
for TAG in "${TAG_ARRAY[@]}"; do
|
|
if ! docker manifest inspect "$REGISTRY_URL/$NAME:$TAG" > /dev/null; then
|
|
echo "❌ Verification failed for $REGISTRY_URL/$NAME:$TAG"
|
|
exit 1
|
|
fi
|
|
echo "✅ Verified image: $REGISTRY_URL/$NAME:$TAG"
|
|
done
|
|
|
|
echo "🚀 Successfully built and pushed image: $REGISTRY_URL/$NAME"
|