Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use aws-cli from base image #149

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ FROM docker:24.0.7
LABEL "maintainer"="whoan <[email protected]>"
LABEL "repository"="https://github.com/whoan/docker-build-with-cache-action"

RUN apk add --no-cache bash grep jq yq aws-cli

COPY docker-build.sh /docker-build.sh
COPY entrypoint.sh /entrypoint.sh

RUN apk add --no-cache bash grep jq yq

ENTRYPOINT ["/entrypoint.sh"]
16 changes: 9 additions & 7 deletions docker-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,12 @@ _push_image_stages() {
docker push "$stage_image"
}

_aws() {
docker run --rm \
--env AWS_ACCESS_KEY_ID="$INPUT_USERNAME" \
--env AWS_SECRET_ACCESS_KEY="$INPUT_PASSWORD" \
--env AWS_SESSION_TOKEN="$INPUT_SESSION" \
amazon/aws-cli:2.1.14 --region "$(_get_aws_region)" "$@"
}
_aws() (
export AWS_ACCESS_KEY_ID
export AWS_SECRET_ACCESS_KEY
export AWS_SESSION_TOKEN
aws --region "$(_get_aws_region)" "$@"
)

_aws_get_public_ecr_registry_name() {
_aws ecr-public describe-registries --output=text --query 'registries[0].aliases[0].name'
Expand Down Expand Up @@ -294,6 +293,9 @@ init_variables() {
if [ -z "$INPUT_SESSION" ]; then
INPUT_SESSION=$AWS_SESSION_TOKEN
fi
AWS_ACCESS_KEY_ID=$INPUT_USERNAME
AWS_SECRET_ACCESS_KEY=$INPUT_PASSWORD
AWS_SESSION_TOKEN=$INPUT_SESSION
fi

# split tags (to allow multiple comma-separated tags)
Expand Down