π Introduction
If youβre tired of manually uploading files to AWS S3 for hosting your static site, then CI/CD with GitHub Actions is the perfect solution.
In this guide, weβll set up:
- An S3 bucket for static hosting
- IAM user with permissions
- GitHub secrets for secure credentials
- GitHub Actions workflow for auto-deployment
By the end, every time you push code to GitHub β your site updates automatically π
π Step 1οΈ : Prepare Your Files
- Make sure you have your
index.html
,style.css
, images, etc. ready in a folder. - Push your project to a GitHub repository.
πͺ£ Step 2 : Create an S3 Bucket
- Go to AWS Management Console β S3.
- Click Create bucket.
- Enter a unique bucket name (e.g.,
portfolio-website
). - Uncheck Block all public access if you want the site to be public.
- Click Create bucket.
βοΈ Step 3 : Configure Bucket for Static Website Hosting
Open created bucket.
Go to the Properties tab of your bucket.
Scroll to Static website hosting β Edit.
-
Enable it and set:
-
Index document:
index.html
-
Error document: (optional, e.g.,
404.html
)
-
Index document:
Save changes.
π Step 4 : Public Access Setup
- Open the Permissions tab and set a bucket policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*"
}
]
}
- Save changes.
- Now the website can be accessed publicly.
π€ Step 5 : Create an IAM User for CI/CD (AWS Console of Your Account)
- Click on Users in the left menu.
- Click the Add users button.
- Enter a username. Click Next.
π Step 6: Set Permissions
- Select Attach policies directly β Create policy β JSON option.
- For deploying a project to S3, use the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:DeleteObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::YOUR_BUCKET_NAME",
"arn:aws:s3:::YOUR_BUCKET_NAME/*"
]
}
]
}
- Click Next, enter a policy name, and create the policy.
- Select created policy for user.
β Step 7: Review and Create User
- Click Next until you reach the Review page.
- Verify the details and click Create user.
π Step 8: Assign Programmatic Access to the User
- Click on the newly created user.
- Go to the Security credentials tab.
- In the Access keys section, click on Create access key.
- Follow the steps to create the access key.
- Copy the Access Key ID and Secret Access Key.
- Download or save them β you wonβt be able to see the secret again.
- The user is now created and has the assigned permissions.
π Step 9 : Add Secrets in GitHub
- Go to your GitHub repo β Settings β Secrets and variables β Actions β New repository secret.
-
Add these secrets:
-
AWS_ACCESS_KEY_ID
β your IAM user key -
AWS_SECRET_ACCESS_KEY
β your IAM user secret -
AWS_REGION
β region of your bucket (e.g.,ap-south-1
) -
S3_BUCKET_NAME
β your bucket name
-
β‘ Step 10 : Create GitHub Actions Workflow
In your project, create folder/file:
.github/workflows/deploy.yml
name: Deploy Website to S3
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Sync files to S3
run: aws s3 sync . s3://${{ secrets.S3_BUCKET_NAME }} --delete
π Step 11 : Deploy Automatically
- Commit and push your code to main branch.
- GitHub Actions will run β upload files to S3 β your website updates automatically π
π Step 12 : Access Your App
- Go to S3 β Properties β Static website hosting.
- Copy the Bucket website endpoint URL.
- Open it in your browser β your HTML + CSS site is live and auto-deployed π
π― Conclusion
With this setup, you now have a CI/CD pipeline that deploys your static site to AWS S3 automatically whenever you push changes to GitHub.
β
No more manual uploads.
β
Faster deployments.
β
Professional workflow like modern DevOps teams.
β Next Steps
π Be interview-ready in the era of AI & Cloud β start your DevOps journey today!
π‘ YouTube wonβt get you a job. Real projects + real internship certificate will.
π₯ AI is reshaping jobs. Donβt watch it happen, be part of it with DevOps & Cloud skills.
π― βΉ2000/month today = Dream job tomorrow. Secure your spot now.
β³ Every month you wait, Cloud + AI jobs are being filled. Donβt miss out!
π DevOps + AWS + AI = The skillset every recruiter is hunting for in 2025.
Top comments (0)