Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add working directory #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@ jobs:

The `access_key_id` and `secret_access_key` are optional and if not provided the EC2 Metadata service will be queried for role based credentials.

## Params

Parameters for setting up the `aws s3 sync` command include:

```
- put: push-to-s3
params:
dir: subdirectory # will change the working directory to subdirectory before invoking the sync
```

## Options

The `options` parameter is synonymous with the options that `aws cli` accepts for `sync`. Please see [S3 Sync Options](http://docs.aws.amazon.com/cli/latest/reference/s3/sync.html#options) and pay special attention to the [Use of Exclude and Include Filters](http://docs.aws.amazon.com/cli/latest/reference/s3/index.html#use-of-exclude-and-include-filters).
Expand Down
6 changes: 4 additions & 2 deletions assets/out
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ payload=`cat`
bucket=$(echo "$payload" | jq -r '.source.bucket')
path=$(echo "$payload" | jq -r '.source.path // ""')
options=$(echo "$payload" | jq -r '.source.options // [] | join(" ")')
dir=$(echo "$payload" | jq -r '.params.dir // "."')

# export for `aws` cli
AWS_ACCESS_KEY_ID=$(echo "$payload" | jq -r '.source.access_key_id // empty')
Expand All @@ -34,8 +35,9 @@ fi
# Export AWS_DEFAULT_REGION if set
[ -n "$AWS_DEFAULT_REGION" ] && export AWS_DEFAULT_REGION

echo "Uploading to S3..."
eval aws s3 sync $source "s3://$bucket/$path" $options
cd "$source/$dir"
echo "Uploading to S3 from '$dir'..."
eval aws s3 sync $source/$dir "s3://$bucket/$path" $options
echo "...done."

source "$(dirname $0)/emit.sh" >&3