Skip to content

Commit

Permalink
Update entrypoint.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
fawadasaurus authored Oct 30, 2023
1 parent 90b82d5 commit a27c1a5
Showing 1 changed file with 24 additions and 27 deletions.
51 changes: 24 additions & 27 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ registry_password="$3"
IFS=' ' read -r -a tags <<< "$4"

if [ -z "$manifest_path" ] || [ -z "$registry_username" ] || [ -z "$registry_password" ]; then
echo "::error::Error: missing or empty input variables"
echo "Error: missing or empty input variables"
exit 1
fi

Expand All @@ -18,7 +18,7 @@ export OCI_PASSWORD="$registry_password"
cd /github/workspace

if [ ! -f "$manifest_path" ]; then
echo "::error::Error: wick file not found at $manifest_path"
echo "Error: wick file not found at $manifest_path"
exit 1
fi

Expand All @@ -33,28 +33,25 @@ do
tag_flags="$tag_flags --tag=$tag"
done

# Store the output in a variable
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
echo "reference=$output" >> "$GITHUB_OUTPUT"

# # Store the output in a variable and capture both stdout and stderr
# output=$(wick registry push "$(basename "$manifest_path")" $tag_flags 2>&1)

# # Check the exit status of the wick command
# if [[ $? -ne 0 ]]; then
# # The wick command failed. Extract the last line of the error output.
# last_line=$(echo "$output" | awk '/Failed to push the package:/ {line=$0} END {print line}')
# echo "::error::wick command failed with output: $last_line"
# exit 1
# fi


# # Process the output with your sequence of commands
# processed_output=$(echo "$output" | grep 'reference' | grep -E '"(\S*)"' | cut -d '"' -f2 | head -1)
# echo $processed_output

# # Write the processed output to the GITHUB_OUTPUT environment file
# echo "::notice::reference=$processed_output" >> "$GITHUB_OUTPUT"
# # Store the output in a variable
# 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
# echo "reference=$output" >> "$GITHUB_OUTPUT"

# Store the output in a variable and capture both stdout and stderr
output=$(wick registry push "$(basename "$manifest_path")" $tag_flags 2>&1)
exit_status=$?

if [[ $exit_status -ne 0 ]]; then
# If there's an error, execute this grep command:
error_output=$(echo "$output" | grep 'Failed to push the package:')
echo "::error file=$manifest_path::wick command failed with output: $error_output" >> "$GITHUB_OUTPUT"
exit 1
else
# If there's no error, execute this grep command:
success_output=$(echo "$output" | grep 'reference' | grep -E '"(\S*)"' | cut -d '"' -f2 | head -1)
echo $success_output
echo "reference=$success_output" >> "$GITHUB_OUTPUT"
fi

0 comments on commit a27c1a5

Please sign in to comment.