{"id":18217326,"url":"https://github.com/asiwomex/s3-cloudfront-static-site-deployment","last_synced_at":"2025-04-07T21:44:06.881Z","repository":{"id":259541313,"uuid":"878168721","full_name":"Asiwomex/s3-cloudfront-static-site-deployment","owner":"Asiwomex","description":"Hosting a static website on Amazon S3 and Cloudfront using Github actions","archived":false,"fork":false,"pushed_at":"2024-10-24T23:11:09.000Z","size":8149,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-13T23:17:22.547Z","etag":null,"topics":["aws","cicd","cloudfront","githubaction-workflow","s3","staticwebsite"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Asiwomex.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-24T22:11:35.000Z","updated_at":"2024-10-24T23:11:13.000Z","dependencies_parsed_at":"2024-12-23T06:38:56.470Z","dependency_job_id":null,"html_url":"https://github.com/Asiwomex/s3-cloudfront-static-site-deployment","commit_stats":null,"previous_names":["asiwomex/s3-cloudfront-static-site-deployment"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asiwomex%2Fs3-cloudfront-static-site-deployment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asiwomex%2Fs3-cloudfront-static-site-deployment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asiwomex%2Fs3-cloudfront-static-site-deployment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Asiwomex%2Fs3-cloudfront-static-site-deployment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Asiwomex","download_url":"https://codeload.github.com/Asiwomex/s3-cloudfront-static-site-deployment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247737120,"owners_count":20987714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","cicd","cloudfront","githubaction-workflow","s3","staticwebsite"],"created_at":"2024-11-03T17:04:48.739Z","updated_at":"2025-04-07T21:44:06.848Z","avatar_url":"https://github.com/Asiwomex.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Continuous Deployment of Static Website to Amazon S3 and CloudFront\n\nThis repository hosts the automation workflow for deploying a **static website** to **Amazon S3** and **Amazon CloudFront** using **GitHub Actions**. The workflow automates the deployment process to the **User Acceptance Testing (UAT)** environment whenever changes are made to the repository.\n\n### READ the following\n1. DOCUMENTATION-Hosting a static website using S3 and Cloudfront.pdf\n2. 1.README.md\n\n## Overview\n\nWe use GitHub Actions to automate the following tasks:\n- Sync the static website files with an **Amazon S3** bucket.\n- Invalidate the **CloudFront** distribution cache to ensure that users get the latest version of the site.\n- Automatically trigger deployments when:\n  - Code is pushed to the `main` or `uat` branches.\n  - A pull request is merged into the `uat` branch.\n  - The workflow is manually dispatched via GitHub.\n\n## Workflow Details\n\nThe GitHub Actions workflow is located in the `.github/workflows/` directory. It triggers on:\n- **Push events** to the `main` and `uat` branches.\n- **Pull requests** that are opened, closed, or reopened, specifically targeting the `uat` branch.\n- **Manual workflow dispatch** via the GitHub Actions interface.\n\n### Workflow Trigger Conditions\n\nThe deployment to the **UAT environment** happens automatically when a **pull request is merged** into the `uat` branch, ensuring that only approved changes are deployed for user acceptance testing.\n\n### Job Steps\n\nThe workflow includes the following steps:\n1. **Checkout Code**: Fetch the latest version of the repository.\n2. **Configure AWS Credentials**: Uses stored AWS secrets (`AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY`) to authenticate with AWS.\n3. **Sync with S3**: Sync the repository files with the specified **S3 bucket** that hosts the static website. Any files that are deleted locally are also deleted in the S3 bucket.\n4. **CloudFront Invalidation**: Invalidate the **CloudFront distribution cache**, ensuring that users see the most up-to-date version of the website.\n\n### Key Variables and Secrets\n\nTo run this workflow, you need to configure the following **secrets** in your GitHub repository:\n\n- `AWS_ACCESS_KEY_ID`: Your AWS Access Key ID with permissions to access S3 and CloudFront.\n- `AWS_SECRET_ACCESS_KEY`: Your AWS Secret Access Key.\n- `AWS_REGION`: The region where your S3 bucket and CloudFront distribution are hosted (e.g., `us-east-1`).\n\n### AWS Resources Used\n- **S3 Bucket**: Stores the static website files and serves the content.\n- **CloudFront**: Provides a Content Delivery Network (CDN) to cache and distribute the website globally for faster access.\n\n## How to Set Up\n\n1. **AWS S3 Bucket**: Create an S3 bucket with static website hosting enabled. Configure your S3 bucket permissions to allow public access to your files (or use CloudFront for secure access).\n   \n2. **CloudFront Distribution**: Set up a CloudFront distribution to cache the content from the S3 bucket. Make sure to get the CloudFront **Distribution ID** as it will be used in the workflow for invalidations.\n\n3. **GitHub Repository**: Create a GitHub repository for your static website files. Store your website files in this repository, and configure the GitHub Actions workflow to deploy them.\n\n4. **Secrets Configuration**: Add your AWS credentials as secrets in your GitHub repository under **Settings \u003e Secrets and variables \u003e Actions**.\n\n## Notes\n1. Ensure that your S3 bucket permissions and CloudFront distribution settings are correctly configured to serve the static website.\n2. Keep your AWS credentials secure by storing them in GitHub Secrets.\n\n## Conclusion\nThis workflow automates the process of deploying a static website to Amazon S3 and CloudFront using GitHub Actions. It ensures that changes are tested and deployed in a controlled manner, making it easier to maintain and update the website with minimal manual effort.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasiwomex%2Fs3-cloudfront-static-site-deployment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasiwomex%2Fs3-cloudfront-static-site-deployment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasiwomex%2Fs3-cloudfront-static-site-deployment/lists"}