commit c3b90db9e6ef354098ee79f0da2ef79ef4753ca9 Author: Skydust Date: Sun Nov 24 11:32:32 2024 +0100 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..57607e4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM public.ecr.aws/docker/library/node:22-alpine3.20 + +# Install git for gitea actions and ansible +RUN apk add --no-cache git curl unzip docker-cli-buildx + +WORKDIR /usr/src + +COPY entrypoint.sh . + +CMD ["/usr/src/entrypoint.sh"] diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..300e622 --- /dev/null +++ b/action.yml @@ -0,0 +1,35 @@ +name: Docker build push ! +description: A custom docker build push +author: Skydust + +# Define your inputs here. +inputs: + imageName: + description: The image name + required: true + imagePrefix: + description: The image prefix + required: false + default: {{ gitea.repositoryUrl }}/${{ gitea.repository_owner }}/ + push: + description: Should push the built image + required: false + default: "true" + pullCache: + description: Uses the pull cache + required: false + default: "true" + +# Define your outputs here. +outputs: + imageName: + description: The full image name + +runs: + using: docker + image: Dockerfile + env: + INPUT_IMAGE_NAME: ${{ inputs.imageName }} + INPUT_IMAGE_PREFIX: ${{ inputs.imagePrefix }} + INPUT_PUSH: ${{ inputs.push }} + INPUT_PULL_CACHE: ${{ inputs.pullCache }} diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..553d4c2 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,29 @@ +#!/bin/sh -l + +IMAGE_NAME="$(echo "$INPUT_IMAGE_PREFIX" | sed 's/^https\?:\/\///')$INPUT_IMAGE_NAME" + +echo "::notice file=entrypoint.sh,line=7::$IMAGE_NAME" + +if [ -z "$INPUT_IMAGE_NAME" ]; then + echo "No image name given." + exit 1 +fi; + +if [ "$INPUT_PUSH" = "true" ]; then + DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --push" +fi + +if [ "$INPUT_PULL_CACHE" = "true" ]; then + # shellcheck disable=SC2089 + DOCKER_BUILD_OPTIONS="${DOCKER_BUILD_OPTIONS} --cache-from \"$IMAGE_NAME\"" + echo "Pulling for cache" + docker pull "$1" || echo "No image found." +fi + +echo "Building and pushing !" +# shellcheck disable=SC2090 +docker buildx build ${DOCKER_BUILD_OPTIONS} -t "$IMAGE_NAME" --progress plain + +echo "imageName=${IMAGE_NAME}" >>"$GITEA_OUTPUT" + +exit 0