Skip to content

Commit

Permalink
fix: added multiple tag support
Browse files Browse the repository at this point in the history
  • Loading branch information
fawadasaurus committed Jun 8, 2023
1 parent db24b9c commit ee34d69
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"'
run: 'echo "Push output: ${{ steps.push.outputs.reference }}"'
9 changes: 4 additions & 5 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -27,6 +26,6 @@ runs:
image: "Dockerfile"
args:
- ${{ inputs.path }}
- ${{ inputs.latest }}
- ${{ inputs.username }}
- ${{ inputs.password }}
- ${{ inputs.tags }}
21 changes: 11 additions & 10 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit ee34d69

Please sign in to comment.