Can't invalidate more than one path?
Jono20201 opened this issue · 3 comments
- name: invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }}
PATHS: "/index.html /service-worker.js /manifest.json"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
Fails with:
An error occurred (InvalidArgument) when calling the CreateInvalidation operation: Your request contains one or more invalid invalidation paths.
Tried a few different permutations with no luck.
That's strange. A space-separated list of paths should definitely work, according to the awscli docs, though I've only used it with a single path myself.
I just pushed a small change to add a debug flag which will print the invalidation command that's executed. Give it a try and make sure the command is what's expected:
- name: invalidate
uses: chetan/invalidate-cloudfront-action@master
env:
DEBUG: "1"
DISTRIBUTION: ${{ secrets.DISTRIBUTION_ID }}
PATHS: "/index.html /service-worker.js /manifest.json"
AWS_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
That's strange. A space-separated list of paths should definitely work, according to the awscli docs, though I've only used it with a single path myself.
Thanks for taking a look, however, I have now found it easier to just use the AWS CLI myself, as this now appears to be provided within the GitHub actions image.
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-1
- name: Upload S3
run: aws s3 sync --delete ./build/ s3://${{ secrets.AWS_S3_BUCKET }}
- name: Invalidate Cloudfront
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.DISTRIBUTION_ID }} --paths /index.html /service-worker.js /manifest.json
Great! I'm glad you found a workaround.
From what you pasted there, it seems the aws cli expects the paths to be passed as individual args, not a single one, so I've updated my script accordingly.