shared-actions/publish-static-contents
Michael Seele 4d2a9815d7
All checks were successful
validate-shared-actions / validate-shared-actions (pull_request) Successful in 48s
Aikido Security PR Check / Aikido Security Scan (pull_request) Successful in 1m23s
fix: update versioning parameters in README and action.yml for clarity
Co-authored-by: Copilot <copilot@github.com>
2026-05-19 15:07:29 +00:00
..
action.yml fix: update versioning parameters in README and action.yml for clarity 2026-05-19 15:07:29 +00:00
README.md fix: update versioning parameters in README and action.yml for clarity 2026-05-19 15:07:29 +00:00

publish-static-contents

Syncs frontend assets to S3 and invalidates a CloudFront distribution. Optionally manages versioned static builds by cleaning up old versions.

Inputs

Input Required Default Description
dist_dir No frontend/dist Path to the frontend dist directory
s3_bucket_name Yes Name of the S3 bucket to sync assets to
cloudfront_distribution_ids No '' Space-separated list of CloudFront distribution IDs to invalidate
versioning No false When true, enables versioned builds. Old versions older than 7 days are deleted, keeping at least the 2 newest
versioning_prefix No '' S3 prefix under which versioned builds are stored (e.g. _static_static/1234567890/). When omitted, versions are stored at the bucket root (e.g. 1234567890/)

Usage

- uses: https://schmalz-git.git.onstackit.cloud/schmalz/shared-actions/publish-static-contents@publish-static-contents-v1
  with:
    s3_bucket_name: my-bucket
    cloudfront_distribution_ids: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}

With versioned static assets at the bucket root:

- uses: https://schmalz-git.git.onstackit.cloud/schmalz/shared-actions/publish-static-contents@publish-static-contents-v1
  with:
    s3_bucket_name: my-bucket
    cloudfront_distribution_ids: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}
    versioning: true

With versioned static assets under a prefix:

- uses: https://schmalz-git.git.onstackit.cloud/schmalz/shared-actions/publish-static-contents@publish-static-contents-v1
  with:
    s3_bucket_name: my-bucket
    cloudfront_distribution_ids: ${{ vars.CLOUDFRONT_DISTRIBUTION_ID }}
    versioning: true
    versioning_prefix: _static

Notes

  • When versioning is true, all assets are synced with Cache-Control: public, max-age=31536000, immutable.
  • index.html is always synced separately with Cache-Control: no-cache, max-age=300 so browsers pick up new deployments quickly.
  • Old versioned builds are pruned: any version folder older than 7 days is deleted, with at least the 2 newest versions always retained.
  • CloudFront invalidation is skipped when cloudfront_distribution_ids is empty.