Skip to content

Commit

Permalink
Use aws configure instead of messy ~/.aws files. Also fixes conflic…
Browse files Browse the repository at this point in the history
…ts (#1).
  • Loading branch information
jakejarvis committed Sep 16, 2019
1 parent 84f1262 commit 244f770
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,23 @@ if [ -z "$AWS_REGION" ]; then
exit 1
fi

# Default to syncing entire repo if SOURCE_DIR not set.
if [ -z "$SOURCE_DIR" ]; then
SOURCE_DIR="."
fi

mkdir -p ~/.aws
touch ~/.aws/credentials

echo "[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/credentials

# Create a dedicated profile for this action to avoid
# conflicts with other actions.
# https://github.com/jakejarvis/s3-sync-action/issues/1
aws configure --profile s3-sync-action <<-EOF
${AWS_ACCESS_KEY_ID}
${AWS_SECRET_ACCESS_KEY}
${AWS_REGION}
text
EOF

# Use our dedicated profile and suppress verbose messages.
# All other flags are optional via `args:` directive.
aws s3 sync ${SOURCE_DIR} s3://${AWS_S3_BUCKET} \
--follow-symlinks \
--delete \
--region ${AWS_REGION} $*

rm -rf ~/.aws
--profile s3-sync-action \
--no-progress $*

0 comments on commit 244f770

Please sign in to comment.