Skip to content

Commit

Permalink
add pre-config labels and tags to existing arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Jun 9, 2024
1 parent b8abe98 commit 12279a1
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,35 @@ BUILD_CMD="nixpacks build $INPUT_CONTEXT"
# Incorporate provided input parameters from actions.yml into the Nixpacks build command
if [ -n "${INPUT_TAGS}" ]; then
read -ra TAGS <<< "$(echo "$INPUT_TAGS" | tr ',\n' ' ')"
for tag in "${TAGS[@]}"; do
BUILD_CMD="$BUILD_CMD --tag $tag"
done
else
# if not tags are provided, assume ghcr.io as the default registry
echo "No tags provided. Defaulting to ghcr.io registry."
BUILD_DATE_TIMESTAMP=$(date +%s)
BUILD_CMD="$BUILD_CMD --tag ghcr.io/$GITHUB_REPOSITORY:$GIT_SHA --tag ghcr.io/$GITHUB_REPOSITORY:latest --tag ghcr.io/$GITHUB_REPOSITORY:$BUILD_DATE_TIMESTAMP"
TAGS=("ghcr.io/$GITHUB_REPOSITORY:$GIT_SHA" "ghcr.io/$GITHUB_REPOSITORY:latest" "ghcr.io/$GITHUB_REPOSITORY:$BUILD_DATE_TIMESTAMP")
fi

BUILD_CMD="$BUILD_CMD --label org.opencontainers.image.source=$GITHUB_REPOSITORY_URL"
# TODO add the description label as well
for tag in "${TAGS[@]}"; do
BUILD_CMD="$BUILD_CMD --tag $tag"
done



if [ -n "${INPUT_LABELS}" ]; then
read -ra LABELS <<< "$(echo "$INPUT_LABELS" | tr ',\n' ' ')"
for label in "${LABELS[@]}"; do
BUILD_CMD="$BUILD_CMD --label $label"
done
fi

LABELS+=("org.opencontainers.image.source=$GITHUB_REPOSITORY_URL")
LABELS+=("org.opencontainers.image.revision=$GITHUB_SHA")
LABELS+=("org.opencontainers.image.created=\"$(date -u +"%Y-%m-%dT%H:%M:%SZ")\"")

# lunchmoney/lunchmoney-assets/Dockerfile:13:7: org.opencontainers.image.licenses="MIT" \
# TODO add the description label as well
# asdf-devcontainer/Dockerfile:9:7:LABEL org.opencontainers.image.authors="Michael Bianco <[email protected]>" \

for label in "${LABELS[@]}"; do
BUILD_CMD="$BUILD_CMD --label $label"
done

if [ -n "${INPUT_PLATFORMS}" ]; then
read -ra PLATFORMS <<< "$(echo "$INPUT_PLATFORMS" | tr ',\n' ' ')"
for platform in "${PLATFORMS[@]}"; do
Expand Down

0 comments on commit 12279a1

Please sign in to comment.