Skip to content

Commit

Permalink
Merge pull request #7 from airuleguy/feature/source-n-dest
Browse files Browse the repository at this point in the history
Initial approach to source and destination configuration.
  • Loading branch information
airuleguy authored Jun 12, 2020
2 parents 9f54b5f + 0365e65 commit 6ebe462
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ LABEL "com.github.actions.description"="Copy a file to an AWS S3 bucket, as long
LABEL "com.github.actions.icon"="copy"
LABEL "com.github.actions.color"="green"

LABEL version="1.0.2"
LABEL version="1.1.0"
LABEL repository="https://github.com/airuleguy/s3-cp-action"
LABEL maintainer="Alejandro Iruleguy <[email protected]>"

Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
uses: airuleguy/s3-cp-action@master
env:
FILE: artifact.jar
SOURCE_PATH: /path/to/jar/
DESTINATION_KEY: /s3/key/
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Expand All @@ -40,6 +42,8 @@ jobs:
| Key | Value | Type | Required |
| ------------- | ------------- | ------------- | ------------- |
| `FILE` | The local file you wish to upload to S3. For example, `./myfile.txt`. | `env` | **Yes** |
| `SOURCE_PATH` | Path where to find `FILE`, can be absolute or relative, must end in `/`. `/path/to/myfile/`. | `env` | **Yes** |
| `DESTINATION_KEY` | Key under which to store `FILE` in S3. This will be concatenated to `AWS_S3_BUCKET` to create the full ARN. `/destination/key/`. | `env` | **Yes** |
| `AWS_REGION` | The region where you created your bucket in. For example, `eu-central-1`. [Full list of regions here.](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions) | `env` | **Yes** |


Expand Down
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ echo "[default]
aws_access_key_id = ${AWS_ACCESS_KEY_ID}
aws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}" > ~/.aws/credentials

(aws s3 ls s3://${AWS_S3_BUCKET}${FILE}) && \
(aws s3 ls s3://${AWS_S3_BUCKET}${DESTINATION_KEY}${FILE}) && \
rm -rf ~/.aws && \
echo "Ooops! Version already exists, aborting upload..." && \
exit 1 \
|| (aws s3 cp ${FILE} s3://${AWS_S3_BUCKET} --region ${AWS_REGION} $*) && rm -rf ~/.aws
|| (aws s3 cp ${SOURCE_PATH}${FILE} s3://${AWS_S3_BUCKET}${DESTINATION_KEY} --region ${AWS_REGION} $*) && rm -rf ~/.aws

0 comments on commit 6ebe462

Please sign in to comment.