Skip to content

Commit

Permalink
Add working directory param
Browse files Browse the repository at this point in the history
Example usage:

```
resources:
- name: <resource name>
  type: <resource type name>
  source:
    access_key_id: {{aws-access-key}}
    secret_access_key: {{aws-secret-key}}
    bucket: {{aws-bucket}}
jobs:
- name: <job name>
  plan:
  - task:
       config:
          platform: linux
          image_resource: *node
          outputs:
              - name: built-project
  - put: <resource name>
     params:
       dir: built-project
```
  • Loading branch information
phillbaker committed Jul 2, 2017
1 parent fbd3f57 commit 49545f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit 49545f9

Please sign in to comment.