Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 49 additions & 22 deletions actions/deploy/s3-cloudfront/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,48 +17,75 @@ outputs:
runs:
using: 'composite'
steps:
- name: Upload new assets to S3
- name: Upload immutable Nuxt assets to S3
shell: bash
run: |
aws s3 sync .output/public/_nuxt/ s3://${{ inputs.s3-bucket }}/_nuxt/ --follow-symlinks \
--exclude "*.map" \
--exclude "builds/*" \
--exclude "manifest.json" \
--cache-control "public,max-age=2592000,immutable"

- name: Upload cacheable static assets to S3
shell: bash
run: |
aws s3 sync .output/public/ s3://${{ inputs.s3-bucket }}/ --follow-symlinks \
--exclude "*.html" --exclude "*.map" \
--exclude "_nuxt/builds/*" --exclude "_nuxt/manifest.json" \
--exclude "robots.txt" --exclude "favicon*" \
--exclude "manifest.json" --exclude "site.webmanifest" \
--exclude "browserconfig.xml" --exclude "sitemap.xml" \
--cache-control "max-age=2592000,public" \
--expires 2034-01-01T00:00:00Z
--exclude "_nuxt/*" \
--exclude "*.html" \
--exclude "*.map" \
--exclude "_payload.json" \
--exclude "*/_payload.json" \
--exclude "robots.txt" \
--exclude "favicon*" \
--exclude "manifest.json" \
--exclude "site.webmanifest" \
--exclude "browserconfig.xml" \
--exclude "sitemap.xml" \
--cache-control "public,max-age=2592000"

- name: Upload HTML and no-cache files to S3
shell: bash
run: |
aws s3 sync .output/public/ s3://${{ inputs.s3-bucket }}/ --follow-symlinks \
--exclude "*" --include "*.html" \
--cache-control "no-cache"
--exclude "*" \
--include "*.html" \
--include "_payload.json" \
--include "*/_payload.json" \
--cache-control "no-cache,max-age=0"

aws s3 sync .output/public/ s3://${{ inputs.s3-bucket }}/ --follow-symlinks \
--exclude "*" \
--include "_nuxt/builds/*" --include "_nuxt/manifest.json" \
--include "robots.txt" --include "favicon*" \
--include "manifest.json" --include "site.webmanifest" \
--include "browserconfig.xml" --include "sitemap.xml" \
--cache-control "no-cache"
--include "_nuxt/builds/*" \
--include "_nuxt/manifest.json" \
--include "robots.txt" \
--include "favicon*" \
--include "manifest.json" \
--include "site.webmanifest" \
--include "browserconfig.xml" \
--include "sitemap.xml" \
--cache-control "no-cache,max-age=0"

- name: Delete stale assets from S3
shell: bash
run: |
aws s3 sync .output/public/ s3://${{ inputs.s3-bucket }}/ --follow-symlinks --delete \
--exclude "cf-logs/*" \
--exclude "_nuxt/*" \
--exclude "*.html" --exclude "*.map" \
--exclude "robots.txt" --exclude "favicon*" \
--exclude "manifest.json" --exclude "site.webmanifest" \
--exclude "browserconfig.xml" --exclude "sitemap.xml" \
--cache-control "max-age=2592000,public" \
--expires 2034-01-01T00:00:00Z
--exclude "*.html" \
--exclude "*.map" \
--exclude "_payload.json" \
--exclude "*/_payload.json" \
--exclude "robots.txt" \
--exclude "favicon*" \
--exclude "manifest.json" \
--exclude "site.webmanifest" \
--exclude "browserconfig.xml" \
--exclude "sitemap.xml" \
Comment on lines 71 to +83

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Stale no-cache artifacts are never removed from S3.

The only --delete sync excludes *.html, _payload.json, site metadata, and all _nuxt/*, while those paths are uploaded in Lines 49-67 without --delete. Removed routes/assets from new builds will remain in S3 and can continue to be served.

Use a dedicated --delete sync for the no-cache include set (same include patterns as Lines 49-67, with no-cache headers), or narrow this exclusion set so those objects participate in deletion safely.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@actions/deploy/s3-cloudfront/action.yml` around lines 71 - 83, The aws s3
sync command with --delete flag at lines 71-83 excludes files like *.html,
_payload.json, and _nuxt/* that are uploaded separately in lines 49-67, causing
stale artifacts to persist in S3 when removed from new builds. Either create a
dedicated aws s3 sync command with --delete that explicitly includes (rather
than excludes) the no-cache file patterns matching lines 49-67 with appropriate
no-cache headers, or remove the exclusions (--exclude "*.html", --exclude
"*/_payload.json", --exclude "_nuxt/*", etc.) from this sync command so those
objects properly participate in deletion when removed from the build. The goal
is to ensure that deleted routes and assets are actually removed from S3 instead
of remaining as stale artifacts.

--cache-control "public,max-age=2592000"

aws s3 rm s3://${{ inputs.s3-bucket }}/ --recursive \
--exclude "*" --include "*.map"
--exclude "*" \
--include "*.map"

- name: Invalidate CloudFront
id: invalidate
Expand Down