This action uploads the contents of the specified directory with proper mime-type and cache-control into S3 bucket and optionally issues an invalidation command to associated cloudfront distribution.
uses: kazimanzurrashid/[email protected]
with:
location: './web/public'
bucket: 'example.com'
uses: kazimanzurrashid/[email protected]
with:
location: './web/public'
bucket: 'example.com'
cache-control: |
private,max-age=31536000: ['**', '!index.html']
invalidate: 'XXXXXXXXXXXXXX'
wait: true
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_SESSION_TOKEN: ${{ secrets.AWS_SESSION_TOKEN }}
The AWS Account needs to have the "s3:PutObject"
permission, if Cloudfront invalidation is enabled
then "cloudfront:CreateInvalidation"
and "cloudfront:GetInvalidation"
are required, if no distribution id
is provided (e.g. invalidate: true
) then "cloudfront:ListDistributions"
is also required.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:PutObject"],
"Resource": "*" // Don't use for production, change it to your s3 bucket name
},
{
"Effect": "Allow",
"Action": [
"cloudfront:CreateInvalidation",
"cloudfront:GetInvalidation",
"cloudfront:ListDistributions"
],
"Resource": "*" // Don't use all, change it to your actual cloudfront distribution
}
]
}
Required. The location of the directory which contents would be uploaded.
Required. The name of the S3 bucket where the content would be uploaded.
Optional. HTTP cache-control mapping. behind the scene it uses globby to find the matching file.
Optional. Boolean
or the id of the cloudfront distribution, the default is false
, if true
then it uses the cloudfront distribution id that is associated with the S3 bucket.
Optional. Boolean
, if true
then it would wait for the invalidation to complete, the default is true
.
Optional, if not specified fallbacks to environment variable.
Optional, if not specified fallbacks to environment variable.
Optional, if not specified fallbacks to environment variable.
Optional, if not specified fallbacks to environment variable.
N/A
name: Web
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node.js setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
npm ci
npm run build
- name: Update
uses: kazimanzurrashid/[email protected]
with:
location: ./build
bucket: my-site.com
cache-control: |
public, max-age=31536000, immutable: '/static/**/**'
max-age=0, no-cache, no-store, must-revalidate: ['./index.html', './'service-worker.js]
invalidate: true
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Web
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node.js setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
npm ci
ng build --configuration production
- name: Update
uses: kazimanzurrashid/[email protected]
with:
location: ./dist/my-ng-app
bucket: my-site.com
cache-control: |
public, max-age=31536000, immutable: ['./**/*.js', './**/*.css', './**/*.png', './**/*.jpg', './assets/**/**']
max-age=0, no-cache, no-store, must-revalidate: ['./index.html']
invalidate: true
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
name: Web
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Node.js setup
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build
run: |
npm ci
npm run build
- name: Update
uses: kazimanzurrashid/[email protected]
with:
location: ./public
bucket: my-site.com
cache-control: |
max-age=0, no-cache, no-store, must-revalidate: ['./**/**/*.html', './page-data/**/**']
public, max-age=31536000, immutable: ['./static/**/**', './*.js', './*.css']
invalidate: true
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
This project is distributed under the MIT license.