This action syncs your static files to S3 and invalidates the CloudFront cache.
Major breaking change: This version now syncs files like aws s3 sync --delete by default:
- ✅ Uploads new and changed files
- ✅ Skips unchanged files (based on MD5/ETag comparison)
- ✅ Deletes files in S3 that don't exist locally (new behavior)
- ✅ Proper async/await flow (fixes race conditions)
- ✅ Better error handling
- ✅ Uses AWS SDK v3
- ✅ Node 20 runtime
This eliminates caching issues caused by old files remaining in S3.
Required The name of the target S3 bucket.
Required The artifacts folder path containing files to deploy.
Optional Delete files in S3 that do not exist locally (sync --delete behavior). Default: true
Set to false to preserve v0.x behavior (upload only, no deletion).
Optional Preview changes without applying them. Default: false
Useful for testing before actual deployment.
Optional Prefix/folder path in S3 bucket. Default: '' (root level)
Optional Bypass the 90% deletion ratio safeguard for adhoc situations. Default: false
Warning: Use with caution. Only enable when you're certain a large deletion is intentional.
Number of files uploaded to S3.
Number of files skipped (unchanged based on MD5 comparison).
Number of files deleted from S3.
- name: Deploy to CloudFront
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist- name: Preview deployment
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist
dry-run: true- name: Deploy without deletion
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist
delete-non-existing: false- name: Deploy to subfolder
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist
s3-prefix: v2/app- name: Deploy with large deletion
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist
bypass-deletion-check: true # Use with caution-
Files are now deleted by default
- v0.x: Only uploaded files, never deleted
- v1.0.0: Syncs files (uploads + deletes orphaned files)
- Migration: Set
delete-non-existing: falseto keep old behavior
-
Node 20 required
- v0.x: node16
- v1.0.0: node20
- Migration: None required (GitHub Actions handles this)
-
Errors now fail the action
- v0.x: Upload errors were logged but didn't fail the action
- v1.0.0: Any error fails the action
- Migration: Fix underlying issues (e.g., missing IAM permissions)
Your IAM role/user now needs the s3:DeleteObject permission:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::your-bucket",
"arn:aws:s3:::your-bucket/*"
]
},
{
"Effect": "Allow",
"Action": [
"cloudfront:ListDistributions",
"cloudfront:CreateInvalidation",
"cloudfront:GetInvalidation"
],
"Resource": "*"
}
]
}-
Test with dry-run first:
- uses: SevenSenders/cloudfront-action@v1 with: s3-bucket-name: my-bucket build-folder-path: ./dist dry-run: true
-
Review what will be deleted: Check the dry-run output to see which files would be removed.
-
Add IAM permission: Ensure your deployment role has
s3:DeleteObjectpermission. -
Deploy to staging first: Test on a non-production environment before updating production workflows.
- List S3 objects - Retrieves all files currently in the S3 bucket
- Scan local files - Walks the build directory and calculates MD5 hashes
- Upload files - Uploads new/changed files (skips unchanged based on ETag comparison)
- Delete orphaned files - Removes S3 files that don't exist locally (if
delete-non-existing: true) - Invalidate CloudFront - Creates cache invalidation (only if changes detected)
- Skips unchanged files - Saves ~80-90% of S3 PUT requests for typical deployments
- Batch deletions - Deletes up to 1000 files per API call
- Controlled concurrency - Uploads 10 files in parallel
- Smart invalidation - Only invalidates if files changed
- Empty folder check - Refuses to sync if local folder is empty (would delete everything)
- Max deletion ratio - Refuses to delete >90% of files in one run (can be bypassed for adhoc situations)
- Dry-run mode - Preview changes before applying
- Detailed logging - Clear output of what changed
For adhoc situations where you need to delete a large portion of files, you can bypass the deletion ratio check:
In GitHub Actions workflow:
- name: Deploy with bypass
uses: SevenSenders/cloudfront-action@v1
with:
s3-bucket-name: my-bucket
build-folder-path: ./dist
bypass-deletion-check: trueWarning: Only use this option when you're certain the deletion is intentional.
Apache-2.0