diff --git a/Dockerfile b/Dockerfile index 2e9d16c..1467b5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG copa_version # Copies your code file from your action repository to the filesystem path `/` of the container -COPY entrypoint.sh /entrypoint.sh +COPY entrypoint.sh /entrypoint.sh # Install required packages RUN apt-get update && \ diff --git a/action.yaml b/action.yaml index 55ebd54..84768e6 100644 --- a/action.yaml +++ b/action.yaml @@ -38,6 +38,8 @@ runs: id: copa-action shell: bash run : | + set -x + # check for copa version input, else use latest if [ -z "${{ inputs.copa-version }}" ]; then latest_tag=$(curl --retry 5 -s "https://api.github.com/repos/project-copacetic/copacetic/releases/latest" | jq -r '.tag_name') @@ -51,13 +53,13 @@ runs: connection="buildx" # check for other methods of connection - if [ -n "{{ inputs.custom-socket }}"]; then + if [ ! -z "${{ inputs.custom-socket }}" ]; then socket="${{ inputs.custom-socket }}" connection="custom-socket" - elif [ -n "${{ inputs.buildkit-version }}" ]; then + elif [ ! -z "${{ inputs.buildkit-version }}" ]; then docker run --net=host --detach --rm --privileged -p 127.0.0.1:8888:8888 --name buildkitd --entrypoint buildkitd moby/buildkit:${{ inputs.buildkit-version }} --addr tcp://0.0.0.0:8888 connection="buildkit-container" fi - + # run copa-action based on inputs - docker run --net=host --mount=type=bind,source=$(pwd),target=/data --mount=type=bind,source="$socket",target="/var/run/docker.sock" --mount=type=bind,source=$GITHUB_OUTPUT,target=$GITHUB_OUTPUT -e GITHUB_OUTPUT --name=copa-action "ghcr.io/project-copacetic/copa-action:v$version" ${{ inputs.image }} ${{ inputs.image-report }} ${{ inputs.patched-tag }} ${{ inputs.timeout }} "$connection" ${{ inputs.format }} {{ inputs.output }} + docker run --net=host --mount=type=bind,source=$(pwd),target=/data --mount=type=bind,source="$socket",target="/var/run/docker.sock" --mount=type=bind,source=$GITHUB_OUTPUT,target=$GITHUB_OUTPUT -e GITHUB_OUTPUT --name=copa-action "ghcr.io/project-copacetic/copa-action:v$version" ${{ inputs.image }} ${{ inputs.image-report }} ${{ inputs.patched-tag }} ${{ inputs.timeout }} ${connection} ${{ inputs.format }} ${{ inputs.output }} diff --git a/entrypoint.sh b/entrypoint.sh index 45930e4..35c4bef 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh set -ex; @@ -8,7 +8,7 @@ patched_tag=$3 timeout=$4 connection_format=$5 format=$6 -output_file=$7 +output_file=$7 # parse image into image name image_no_tag=$(echo "$image" | cut -d':' -f1) @@ -28,15 +28,15 @@ case "$connection_format" in docker buildx create --name=copa-action docker buildx use --default copa-action connection="--addr buildx://copa-action" - ;; + ;; # through a running buildkit container over tcp "buildkit-container") connection="--addr tcp://127.0.0.1:8888" - ;; + ;; # through the default docker buildkit endpoint enabled with a custom socket "custom-socket") connection="" - ;; + ;; esac # run copa to patch image