From ee34d6974bf654478d272020d739eb0513ace22f Mon Sep 17 00:00:00 2001 From: Fawad Shaikh Date: Thu, 8 Jun 2023 14:59:24 -0400 Subject: [PATCH] fix: added multiple tag support --- .github/workflows/test.yaml | 4 ++-- action.yaml | 9 ++++----- entrypoint.sh | 21 +++++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 9784247..4fd8089 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -12,8 +12,8 @@ jobs: id: push with: path: ./tests/test_app.wick - latest: "true" username: ${{ secrets.CANDLE_REGISTRY_USERNAME }} password: ${{ secrets.CANDLE_REGISTRY_PASSWORD }} + tags: latest abc123 123456 - name: Print push output - run: 'echo "Push output: ${{ steps.push.outputs.reference }}"' \ No newline at end of file + run: 'echo "Push output: ${{ steps.push.outputs.reference }}"' diff --git a/action.yaml b/action.yaml index a829dc2..e24448f 100644 --- a/action.yaml +++ b/action.yaml @@ -9,16 +9,15 @@ inputs: description: "Path to the main wick manifest file. Usually the file name is `app.wick` or `component.wick`. This must contain the registry configuration details in the `package` section." required: true default: "app.wick" - latest: - description: "If set to true, the image will have a second tag of latest appended in addition to the version tag" - required: true - default: "true" username: description: "Username for registry configured in the Wick manifest" required: true password: description: "Password for registry configured in the Wick manifest" required: true + tags: + description: "Space-separated list of additional tags to apply to the image. This is optional as push will always set the tag to the version in the manifest." + required: false outputs: reference: description: "The image reference that was pushed" @@ -27,6 +26,6 @@ runs: image: "Dockerfile" args: - ${{ inputs.path }} - - ${{ inputs.latest }} - ${{ inputs.username }} - ${{ inputs.password }} + - ${{ inputs.tags }} diff --git a/entrypoint.sh b/entrypoint.sh index a18376b..a6c8786 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -3,11 +3,11 @@ set -e manifest_path="$1" -latest="$2" -registry_username="$3" -registry_password="$4" +registry_username="$2" +registry_password="$3" +IFS=' ' read -r -a tags <<< "$4" -if [ -z "$manifest_path" ] || [ -z "$latest" ] || [ -z "$registry_username" ] || [ -z "$registry_password" ]; then +if [ -z "$manifest_path" ] || [ -z "$registry_username" ] || [ -z "$registry_password" ]; then echo "Error: missing or empty input variables" exit 1 fi @@ -26,14 +26,15 @@ fi manifest_dir=$(dirname "$manifest_path") cd "$manifest_dir" -latest_flag="" - -if [ "$latest" = "true" ]; then - latest_flag="--latest" -fi +#create additional tags list for image +tag_flags="" +for tag in "${tags[@]}" +do + tag_flags="$tag_flags --tag=$tag" +done # Store the output in a variable -output=$(wick registry push "$(basename "$manifest_path")" $latest_flag 2>&1 | grep 'reference' | grep -E '"(\S*)"' | cut -d '"' -f2 | head -1) +output=$(wick registry push "$(basename "$manifest_path")" $tag_flags 2>&1 | grep 'reference' | grep -E '"(\S*)"' | cut -d '"' -f2 | head -1) echo $output # Write the output to the GITHUB_OUTPUT environment file