accept the incoming JSON config data
This commit is contained in:
parent
bfb34616f4
commit
5dcef5d5f1
4 changed files with 20 additions and 9 deletions
|
@ -1,6 +1,3 @@
|
||||||
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup
|
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup
|
||||||
AWS_ACCESS_KEY_ID=<key>
|
AWS_ACCESS_KEY_ID=<key>
|
||||||
AWS_SECRET_ACCESS_KEY=<secret>
|
AWS_SECRET_ACCESS_KEY=<secret>
|
||||||
|
|
||||||
# exclude the `s3://` prefix/protocol
|
|
||||||
S3_BUCKET=<bucket name>
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ Requires Docker.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
|
|
||||||
# modify .env
|
# modify .env
|
||||||
./script/run /full/path/to/dir/or/file
|
|
||||||
|
# exclude the `s3://` prefix/protocol for the `bucket`
|
||||||
|
./script/run </full/path/to/dir/or/file> <bucket>
|
||||||
```
|
```
|
||||||
|
|
10
assets/out
10
assets/out
|
@ -1,5 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
|
# http://concourse.ci/implementing-resources.html#out:-update-a-resource.
|
||||||
|
|
||||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
|
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -14,9 +16,15 @@ if [ -z "$source" ]; then
|
||||||
fi
|
fi
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
# parse incoming config data
|
||||||
|
payload=`cat`
|
||||||
|
bucket=$(echo "$payload" | jq -r '.source.bucket')
|
||||||
|
|
||||||
|
echo "Uploading to S3..."
|
||||||
# credentials are provided via environment variables
|
# credentials are provided via environment variables
|
||||||
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
||||||
aws s3 sync $source "s3://$S3_BUCKET"
|
aws s3 sync $source "s3://$bucket"
|
||||||
|
echo "...done."
|
||||||
|
|
||||||
# use the current UNIX time as the version
|
# use the current UNIX time as the version
|
||||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L133-L136
|
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L133-L136
|
||||||
|
|
11
script/run
11
script/run
|
@ -1,19 +1,22 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
set -x
|
|
||||||
|
|
||||||
source=$1
|
source=$1
|
||||||
|
bucket=$2
|
||||||
|
|
||||||
if [ -z "$source" ]; then
|
if [ -z "$source" ] || [ -z "$bucket" ]; then
|
||||||
echo "usage: $0 </full/path/to/dir/or/file>"
|
echo "usage: $0 </full/path/to/dir/or/file> <bucket>"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
docker build -t 18fgsa/s3-resource-simple .
|
docker build -t 18fgsa/s3-resource-simple .
|
||||||
|
|
||||||
docker run \
|
json="{\"source\": {\"bucket\": \"$bucket\"}}"
|
||||||
|
|
||||||
|
echo $json | docker run \
|
||||||
--env-file .env \
|
--env-file .env \
|
||||||
|
-i \
|
||||||
--rm \
|
--rm \
|
||||||
-v $source:/tmp/input \
|
-v $source:/tmp/input \
|
||||||
18fgsa/s3-resource-simple \
|
18fgsa/s3-resource-simple \
|
||||||
|
|
Loading…
Reference in a new issue