46 lines
1.2 KiB
YAML
46 lines
1.2 KiB
YAML
name: cloudfront-invalidate
|
|
description: Invalidate one or more CloudFront distributions
|
|
|
|
inputs:
|
|
distribution-ids:
|
|
description: Space-separated CloudFront distribution IDs, or path to file containing them
|
|
required: true
|
|
paths:
|
|
description: Invalidation paths
|
|
required: false
|
|
default: "/*"
|
|
aws-role-arn:
|
|
description: IAM role via OIDC
|
|
required: true
|
|
aws-profile:
|
|
description: AWS CLI profile name
|
|
required: false
|
|
default: default
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- uses: schmalz/shared-actions/.github/actions/aws-configure@v1
|
|
with:
|
|
role-arn: ${{ inputs.aws-role-arn }}
|
|
aws-profile: ${{ inputs.aws-profile }}
|
|
|
|
- run: |
|
|
DISTRIBUTION_IDS="${{ inputs.distribution-ids }}"
|
|
PATHS="${{ inputs.paths }}"
|
|
AWS_PROFILE="${{ inputs.aws-profile }}"
|
|
|
|
# Check if distribution-ids is a file path or literal IDs
|
|
if [ -f "$DISTRIBUTION_IDS" ]; then
|
|
IDS=$(cat "$DISTRIBUTION_IDS")
|
|
else
|
|
IDS="$DISTRIBUTION_IDS"
|
|
fi
|
|
|
|
for DIST_ID in $IDS; do
|
|
aws cloudfront create-invalidation \
|
|
--distribution-id "$DIST_ID" \
|
|
--paths "$PATHS" \
|
|
--profile "$AWS_PROFILE"
|
|
done
|
|
shell: bash
|