Skip to content

Commit 83eb8ae

Browse files
committed
Update docs
1 parent ec209d1 commit 83eb8ae

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# GitHub Action to Sync S3 Bucket 🔄
1+
# GitHub Action to Sync S3 Bucket and invalidate the CloudFront cache 🔄
22

3-
This simple action uses the [vanilla AWS CLI](https://docs.aws.amazon.com/cli/index.html) to sync a directory (either from your repository or generated during your workflow) with a remote S3 bucket.
3+
This simple action uses the [vanilla AWS CLI](https://docs.aws.amazon.com/cli/index.html) to sync a directory (either from your repository or generated during your workflow) with a remote S3 bucket and afterwards invalidate the CloudFront cache.
44

55

66
## Usage
@@ -30,16 +30,18 @@ jobs:
3030
deploy:
3131
runs-on: ubuntu-latest
3232
steps:
33-
- uses: actions/checkout@master
34-
- uses: jakejarvis/s3-sync-action@master
33+
- uses: actions/checkout@v2
34+
- uses: kersvers/s3-sync-action@master
3535
with:
3636
args: --acl public-read --follow-symlinks --delete
3737
env:
38-
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
3938
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
4039
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
41-
AWS_REGION: 'us-west-1' # optional: defaults to us-east-1
40+
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
41+
DISTRIBUTION_ID: 'EQDXXXXO18XXX'
42+
AWS_REGION: 'eu-west-1' # optional: defaults to us-east-1
4243
SOURCE_DIR: 'public' # optional: defaults to entire repository
44+
DEST_DIR: 'subdirectory' # optional: defaults to the root of the bucket
4345
```
4446
4547
@@ -52,6 +54,7 @@ The following settings must be passed as environment variables as shown in the e
5254
| `AWS_ACCESS_KEY_ID` | Your AWS Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret env` | **Yes** | N/A |
5355
| `AWS_SECRET_ACCESS_KEY` | Your AWS Secret Access Key. [More info here.](https://docs.aws.amazon.com/general/latest/gr/managing-aws-access-keys.html) | `secret env` | **Yes** | N/A |
5456
| `AWS_S3_BUCKET` | The name of the bucket you're syncing to. For example, `jarv.is` or `my-app-releases`. | `secret env` | **Yes** | N/A |
57+
| `DISTRIBUTION_ID` | The ID of the CloudFront distribution you wish to invalidate the cache for. | `env` | **Yes** | N/A |
5558
| `AWS_REGION` | The region where you created your bucket. Set to `us-east-1` by default. [Full list of regions here.](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions) | `env` | No | `us-east-1` |
5659
| `AWS_S3_ENDPOINT` | The endpoint URL of the bucket you're syncing to. Can be used for [VPC scenarios](https://aws.amazon.com/blogs/aws/new-vpc-endpoint-for-amazon-s3/) or for non-AWS services using the S3 API, like [DigitalOcean Spaces](https://www.digitalocean.com/community/tools/adapting-an-existing-aws-s3-application-to-digitalocean-spaces). | `env` | No | Automatic (`s3.amazonaws.com` or AWS's region-specific equivalent) |
5760
| `SOURCE_DIR` | The local directory (or file) you wish to sync/upload to S3. For example, `public`. Defaults to your entire repository. | `env` | No | `./` (root of cloned repository) |

entrypoint.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
set -e
44

5-
if [ -z "$AWS_S3_BUCKET" ]; then
6-
echo "AWS_S3_BUCKET is not set. Quitting."
7-
exit 1
8-
fi
9-
105
if [ -z "$AWS_ACCESS_KEY_ID" ]; then
116
echo "AWS_ACCESS_KEY_ID is not set. Quitting."
127
exit 1
@@ -17,6 +12,11 @@ if [ -z "$AWS_SECRET_ACCESS_KEY" ]; then
1712
exit 1
1813
fi
1914

15+
if [ -z "$AWS_S3_BUCKET" ]; then
16+
echo "AWS_S3_BUCKET is not set. Quitting."
17+
exit 1
18+
fi
19+
2020
if [ -z "$DISTRIBUTION_ID" ]; then
2121
echo "DISTRIBUTION_ID is not set. Quitting."
2222
exit 1
@@ -48,7 +48,7 @@ sh -c "aws s3 sync ${SOURCE_DIR:-.} s3://${AWS_S3_BUCKET}/${DEST_DIR} \
4848
--profile s3-sync-action \
4949
--no-progress \
5050
${ENDPOINT_APPEND} $*"
51-
51+
5252
sh -c "aws cloudfront create-invalidation --distribution-id ${DISTRIBUTION_ID} --paths "/*" --profile s3-sync-action"
5353

5454
# Clear out credentials after we're done.

0 commit comments

Comments
 (0)