Merge pull request #6 from 18F/check_timestamp

Check timestamp
This commit is contained in:
Aidan Feldman 2016-03-23 12:41:31 -04:00
commit 32eebc49aa
2 changed files with 14 additions and 2 deletions

View file

@ -68,3 +68,5 @@ Requires [Docker](https://www.docker.com/).
* Exclude the `s3://` prefix/protocol for `bucket`. * Exclude the `s3://` prefix/protocol for `bucket`.
1. Run `./test/out </full/path/to/dir>`. 1. Run `./test/out </full/path/to/dir>`.
1. Run `./test/in </full/path/to/dir>`.
1. Run `./test/check`.

View file

@ -4,5 +4,15 @@
set -e set -e
# pretend that "the given version is already the latest" # parse incoming config data
echo "[]" payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
# 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}')"
recent="$(echo $timestamps | jq -r 'max_by(.LastModified)')"
echo "[$recent]"