Skip to content

Commit

Permalink
docs: updated readme; added changelog for 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
chetan committed May 31, 2020
1 parent 0b42faf commit 00d5003
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 2 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Invalidate Cloudfront Action Changelog

## v1.3

### Additions

* added PATHS_FROM option for reading invalidation paths from the given file

## v1.2

### Fixes

* Fix invalidation of multiple paths

## v1.1

### Fixes

* invalidation of multiple space-separated paths

### Additions

* added DEBUG="1" flag for extra troubleshooting.

## v1.0

First cut! Works as advertised.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,68 @@ jobs:

```

### Configuration
## Configuration

Param | Required? | Description
----- | --------- | -----------
PATHS | yes* | A list of one or more space-separated paths to invalidate
PATHS_FROM | yes* | Filename to read list of paths from
DISTRIBUTION | yes | Cloudfront distribution ID to operate on, e.g., 'EDFDVBD6EXAMPLE'
PATHS | yes | A list of one or more space-separated paths to invalidate
AWS_REGION | yes | AWS Region to operate in
AWS_ACCESS_KEY_ID | yes | Access key with necessary permissions to invalidate objects in the target distribution (see below)
AWS_SECRET_ACCESS_KEY | yes | Secret key
DEBUG | no | When set to "1", prints the final awscli invalidation command for troubleshooting purposes

__Note__: *either* `PATHS` or `PATHS_FROM` is required. `PATHS_FROM` will
overwrite `PATHS` if both are set.

See also: [AWS CLI reference](https://docs.aws.amazon.com/cli/latest/reference/cloudfront/create-invalidation.html)

### Paths

Paths are passed directly to the aws cli `create-invalidation` command and so
must be a proper space-separated list of paths. Examples:

```sh
PATHS=/index.html
PATHS=/ /index.html /foo/bar/baz
```

Alternatively, you can write the list of files to invalidate to a file which
will then be slurped into the PATHS variable. This lets you use some other
method to dynamically generate the list of files based on the commit, etc.
Example workflow steps:

```yaml
- name: checkout dist
uses: actions/checkout@master
with:
ref: dist
# need at least 2 here so we can get a proper log in next step
fetch-depth: 2

- name: get updated files
run: |
# no pipefail so we can allow grep to fail quietly
set -e
FILES=$(git log --stat="1000" -1 | grep '|' | awk '{print "/"$1}' | grep -e '\.html$')
[ -z "$FILES" ] && touch .updated_files && exit 0
for file in $FILES; do
echo $file
# add bare directory to list of updated paths when we see index.html
[[ "$file" == *"/index.html" ]] && echo $file | sed -e 's/\/index.html$/\//'
done | sort | uniq | tr '\n' ' ' > .updated_filess
- name: invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
PATHS_FROM: .updated_files
AWS_REGION: 'us-east-1'
DISTRIBUTION: ${{ secrets.DISTRIBUTION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
```
### AWS IAM Policy
In order to use this action, you will need to supply an access key pair which has, at minimum, the following permission:
Expand Down

0 comments on commit 00d5003

Please sign in to comment.