s3-resource-simple/assets/out

32 lines
885 B
Text
Raw Normal View History

2016-03-10 08:16:03 +01:00
#!/bin/sh
2016-03-10 07:32:05 +01:00
# Resource Impl: http://concourse.ci/implementing-resources.html#out:-update-a-resource.
2016-03-10 07:32:05 +01:00
set -e
exec 3>&1 # make stdout available as fd 3 for the result
exec 1>&2 # redirect all output to stderr for logging
source=$1
if [ -z "$source" ]; then
echo "usage: $0 </full/path/to/dir>"
exit 1
fi
#######################################
2016-03-10 09:57:41 +01:00
# parse incoming config data
payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
path=$(echo "$payload" | jq -r '.source.path // ""')
options=$(echo "$payload" | jq -r '.source.options // [] | join(" ")')
2016-03-10 09:57:41 +01:00
# export for `aws` cli
export AWS_ACCESS_KEY_ID=$(echo "$payload" | jq -r '.source.access_key_id')
export AWS_SECRET_ACCESS_KEY=$(echo "$payload" | jq -r '.source.secret_access_key')
echo "Uploading to S3..."
eval aws s3 sync $source "s3://$bucket/$path" $options
2016-03-10 09:57:41 +01:00
echo "...done."
source "$(dirname $0)/emit.sh" >&3