finish up the out
script
also add a `run` script for testing purposes
This commit is contained in:
parent
0f17495982
commit
2202ac6080
6 changed files with 58 additions and 6 deletions
6
.env.example
Normal file
6
.env.example
Normal file
|
@ -0,0 +1,6 @@
|
|||
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-set-up.html#cli-signup
|
||||
AWS_ACCESS_KEY_ID=<key>
|
||||
AWS_SECRET_ACCESS_KEY=<secret>
|
||||
|
||||
# exclude the `s3://` prefix/protocol
|
||||
S3_BUCKET=<bucket name>
|
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.env
|
|
@ -6,5 +6,3 @@ RUN pip install --upgrade pip
|
|||
RUN pip install --upgrade awscli
|
||||
|
||||
ADD assets/ /opt/resource/
|
||||
|
||||
CMD echo Simple S3 Resource ready.
|
||||
|
|
11
README.md
11
README.md
|
@ -1,10 +1,17 @@
|
|||
# Simple S3 Resource for [Concourse CI](http://concourse.ci)
|
||||
|
||||
Resource to upload files to S3. Unlike the [the official S3 Resource](https://github.com/concourse/s3-resource), this Resource doesn't care about files being versioned.
|
||||
|
||||
## Usage
|
||||
|
||||
TODO
|
||||
|
||||
## Development
|
||||
|
||||
Requires Docker.
|
||||
|
||||
```bash
|
||||
docker build -t s3-resource-simple .
|
||||
docker run --rm s3-resource-simple /opt/resource/out
|
||||
cp .env.example .env
|
||||
# modify .env
|
||||
./script/run /full/path/to/dir/or/file
|
||||
```
|
||||
|
|
24
assets/out
24
assets/out
|
@ -1,6 +1,26 @@
|
|||
#!/bin/sh
|
||||
|
||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L4-L16
|
||||
set -e
|
||||
set -x
|
||||
|
||||
echo foo
|
||||
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 <path/to/volume>"
|
||||
exit 1
|
||||
fi
|
||||
#######################################
|
||||
|
||||
# credentials are provided via environment variables
|
||||
# http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment
|
||||
aws s3 sync $source "s3://$S3_BUCKET"
|
||||
|
||||
# use the current UNIX time as the version
|
||||
# https://github.com/concourse/git-resource/blob/6fcfbd4/assets/out#L133-L136
|
||||
jq -n "{
|
||||
version: {
|
||||
timestamp: $(date +%s)}
|
||||
}" >&3
|
||||
|
|
20
script/run
Executable file
20
script/run
Executable file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
set -x
|
||||
|
||||
source=$1
|
||||
|
||||
if [ -z "$source" ]; then
|
||||
echo "usage: $0 </full/path/to/dir/or/file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker build -t s3-resource-simple .
|
||||
|
||||
docker run \
|
||||
--env-file .env \
|
||||
--rm \
|
||||
-v $source:/tmp/input \
|
||||
s3-resource-simple \
|
||||
/opt/resource/out /tmp/input
|
Loading…
Reference in a new issue