2 Commits
v1.2 ... v1.4

View File

@@ -10,6 +10,35 @@ on:
required: true
type: string
checkout_repo:
description: >
Optional external repo to checkout (owner/name). If set, repo is checked out
into checkout_path.
required: false
type: string
default: ""
checkout_ref:
description: >
Optional git ref (branch/tag/SHA) for checkout_repo. Defaults to repo default branch.
required: false
type: string
default: ""
checkout_path:
description: >
Path to checkout checkout_repo into.
required: false
type: string
default: "external-src"
checkout_fetch_depth:
description: >
Fetch depth for checkout_repo (0 = full history).
required: false
type: string
default: "0"
registry_host:
required: true
type: string
@@ -21,6 +50,14 @@ on:
description: >
Multiline build args, one per line: KEY=VALUE (values may include spaces)
extra_tags:
description: >
Optional extra tags to apply to each image.
Accepts JSON array (e.g. ["latest", "main"]) or newline-separated list.
required: false
type: string
default: ""
env:
description: >
Multiline env vars, one per line: KEY=VALUE
@@ -53,6 +90,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout external repository
if: ${{ inputs.checkout_repo != '' }}
uses: actions/checkout@v4
with:
repository: ${{ inputs.checkout_repo }}
ref: ${{ inputs.checkout_ref }}
server-url: ${{ github.server_url }}
token: ${{ secrets.ci_token }}
path: ${{ inputs.checkout_path }}
fetch-depth: ${{ inputs.checkout_fetch_depth }}
- name: Load env vars
if: ${{ inputs.env != '' }}
run: |
@@ -98,6 +146,7 @@ jobs:
env:
IMAGES: ${{ inputs.images }}
BUILD_ARGS: ${{ inputs.build_args }}
EXTRA_TAGS_INPUT: ${{ inputs.extra_tags }}
CI_TOKEN: ${{ secrets.ci_token }}
TRIVY_SEVERITY: ${{ inputs.trivy_severity }}
run: |
@@ -137,6 +186,25 @@ jobs:
VERSION_TAGS+=("latest")
fi
EXTRA_TAGS=()
if [ -n "$EXTRA_TAGS_INPUT" ]; then
if echo "$EXTRA_TAGS_INPUT" | jq -e . >/dev/null 2>&1; then
if ! echo "$EXTRA_TAGS_INPUT" | jq -e 'type == "array"' >/dev/null 2>&1; then
echo "inputs.extra_tags must be a JSON array" >&2
exit 1
fi
mapfile -t EXTRA_TAGS < <(echo "$EXTRA_TAGS_INPUT" | jq -r '.[]')
else
while IFS= read -r line; do
trimmed="${line#"${line%%[![:space:]]*}"}"
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
[ -z "$trimmed" ] && continue
case "$trimmed" in \#*) continue;; esac
EXTRA_TAGS+=("$trimmed")
done <<< "$EXTRA_TAGS_INPUT"
fi
fi
BUILD_ARG_FLAGS=()
BUILD_ARGS_JSON="{}"
if [ -n "$BUILD_ARGS" ]; then
@@ -216,6 +284,9 @@ jobs:
for ver in "${VERSION_TAGS[@]}"; do
TAGS+=("$FULL_IMAGE:$ver")
done
for extra in "${EXTRA_TAGS[@]}"; do
TAGS+=("$FULL_IMAGE:$extra")
done
TAGS_JSON=$(printf '%s\n' "${TAGS[@]}" | jq -R . | jq -s .)
TARGET_NAME="img_${IDX}"
@@ -275,6 +346,9 @@ jobs:
for ver in "${VERSION_TAGS[@]}"; do
TAGS+=("$FULL_IMAGE:$ver")
done
for extra in "${EXTRA_TAGS[@]}"; do
TAGS+=("$FULL_IMAGE:$extra")
done
TAG_ARGS=()
for tag in "${TAGS[@]}"; do