Skip to content

Commit

Permalink
Fix aws calls
Browse files Browse the repository at this point in the history
  • Loading branch information
whoan committed Nov 19, 2022
1 parent 2144a54 commit f0f83b6
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,12 @@ _parse_extra_args() {
init_variables() {
DUMMY_IMAGE_NAME="$INPUT_IMAGE_NAME":tmp_tag_ignore
BUILD_LOG=build-output.log

if [ -z "$INPUT_USERNAME" ] && _is_aws_ecr; then
INPUT_USERNAME=$AWS_ACCESS_KEY_ID
INPUT_PASSWORD=$AWS_SECRET_ACCESS_KEY
fi

# split tags (to allow multiple comma-separated tags)
IFS=, read -ra INPUT_IMAGE_TAG <<< "$INPUT_IMAGE_TAG"
if ! _set_namespace; then
Expand All @@ -238,6 +244,12 @@ init_variables() {
fi
}

check_aws_cli() {
if _is_aws_ecr; then
_aws --version
fi
}

check_required_input() {
echo -e "\n[Action Step] Checking required input..."
#shellcheck disable=SC2128
Expand All @@ -249,11 +261,6 @@ check_required_input() {

login_to_registry() {
echo -e "\n[Action Step] Log in to registry..."
if [ -z "$INPUT_USERNAME" ] && _is_aws_ecr; then
INPUT_USERNAME=$AWS_ACCESS_KEY_ID
INPUT_PASSWORD=$AWS_SECRET_ACCESS_KEY
fi

if _has_value USERNAME "${INPUT_USERNAME}" && _has_value PASSWORD "${INPUT_PASSWORD}"; then
_docker_login && return 0
echo "Could not log in (please check credentials)" >&2
Expand Down Expand Up @@ -344,6 +351,7 @@ logout_from_registry() {


# run the action
check_aws_cli
init_variables
check_required_input
login_to_registry
Expand Down

0 comments on commit f0f83b6

Please sign in to comment.