Merge pull request #10 from knifhen/path_param

added optional parameter path to sync to path in bucket
This commit is contained in:
Aidan Feldman 2016-10-04 11:02:44 -04:00 committed by GitHub
commit abda2b8908
4 changed files with 7 additions and 3 deletions

View file

@ -19,6 +19,7 @@ resources:
access_key_id: {{aws-access-key}}
secret_access_key: {{aws-secret-key}}
bucket: {{aws-bucket}}
path: [<optional>, use to sync to a specific path of the bucket instead of root of bucket]
options: [<optional, see note below>]
jobs:
- name: <job name>

View file

@ -7,12 +7,13 @@ set -e
# parse incoming config data
payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
prefix="$(echo "$payload" | jq -r '.source.path // ""')"
# 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')
# Consider the most recent LastModified timestamp as the most recent version.
timestamps="$(aws s3api list-objects --bucket $bucket --query 'Contents[].{LastModified: LastModified}')"
timestamps=$(aws s3api list-objects --bucket $bucket --prefix "$prefix" --query 'Contents[].{LastModified: LastModified}')
recent="$(echo $timestamps | jq -r 'max_by(.LastModified)')"
echo "[$recent]"

View file

@ -17,6 +17,7 @@ fi
# 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(" ")')
# export for `aws` cli
@ -24,7 +25,7 @@ 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 "Downloading from S3..."
eval aws s3 sync "s3://$bucket" $dest $options
eval aws s3 sync "s3://$bucket/$path" $dest $options
echo "...done."
source "$(dirname $0)/emit.sh" >&3

View file

@ -17,6 +17,7 @@ fi
# 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(" ")')
# export for `aws` cli
@ -24,7 +25,7 @@ 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" $options
eval aws s3 sync $source "s3://$bucket/$path" $options
echo "...done."
source "$(dirname $0)/emit.sh" >&3