Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmuzina/deploy_s3_with_cloudfront_invalidation
Github Action that deploys an artifact to an S3 bucket, and invalidates a Cloudfront invalidation. Used to standardize S3 deployment of my web applications.
https://github.com/jmuzina/deploy_s3_with_cloudfront_invalidation
aws cicd cloudfront github-actions s3
Last synced: about 1 month ago
JSON representation
Github Action that deploys an artifact to an S3 bucket, and invalidates a Cloudfront invalidation. Used to standardize S3 deployment of my web applications.
- Host: GitHub
- URL: https://github.com/jmuzina/deploy_s3_with_cloudfront_invalidation
- Owner: jmuzina
- Created: 2024-02-20T23:34:11.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-02-21T01:29:01.000Z (10 months ago)
- Last Synced: 2024-10-13T08:11:07.376Z (2 months ago)
- Topics: aws, cicd, cloudfront, github-actions, s3
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Deploy S3 With Cloudfront Invalidation
Deploys an artifact to Amazon S3, and creates a Cloudfront Invalidation to ensure the latest files are served.## Inputs:
Name
Description
Type
Default
environment
Name of the environment you are deploying the artifact to
string
prod
cloudfront_invalidation
Path or pattern within your web artifact for which to create a Cloudfront invalidation
string
/*
## Secrets:
Name
Description
AWS_S3_BUCKET_NAME
Name of the S3 bucket to upload static web build artifacts to
AWS_ACCESS_KEY_ID
AWS IAM Access Key ID for accessing resources
AWS_SECRET_ACCESS_KEY
AWS IAM Secret Access Key for accessing resources
AWS_CLOUDFRONT_DISTRIBUTION_ID
ID of the Cloudfront Distribution used by this artifact
AWS_REGION
AWS deployment region. See AWS Docs for list of valid values.
## Artifact name
Note: in your CI step before calling this workflow, you **must** upload your build artifact using
[actions/upload-artifact](https://github.com/actions/upload-artifact) and assign the artifact name using the format
`${{ github.event.repository.name }}-${{ environment }}-${{ github.run_number }}`, where `environment` is some string
to distinguish runs of the same repository but different environment.## Example:
```yaml
jobs:
build:
name: Build
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout Repo
uses: actions/checkout@v2- name: Install JS dependencies
run: npm i- name: Build artifact
run: npm run build- name: Archive build artifact
uses: actions/upload-artifact@v4
with:
# Artifact name must match naming convention ${{ github.event.repository.name }}-${{ environment }}-${{ github.run_number }}
name: ${{ github.event.repository.name }}-dev-${{ github.run_number }}
path: ./dist/your_project_name
deploy:
needs: build
name: Deploy
uses: 'jmuzina/deploy_s3_with_cloudfront_invalidation/.github/workflows/[email protected]'
with:
environment: dev
secrets:
# Make sure you store your secrets in repository actions secrets. Do not store them in cleartext for security reasons.
AWS_S3_BUCKET_NAME: ${{ secrets.AWS_S3_BUCKET_NAME }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID }}
AWS_REGION: ${{ secrets.AWS_REGION }}
```