DevOps Project-7
Project Description
The project involves deploying a Portfolio app on AWS S3 using GitHub Actions. Git Hub actions allows you to perform CICD with GitHub Repository integrated.
Automated Portfolio Deployment with GitHub Actions on AWS S3
Step 1: GitHub Repository Setup
Begin by creating a new public GitHub repository. Once created, upload your code to this repository.
OR You can fork this one:
Step 2: S3 Bucket Configuration
a. Create an S3 Bucket: Choose the region and assign a unique bucket name.
Ensure Object ownership ACLs are enabled and uncheck blocked public access.
Click "Create."
b. Open the S3 bucket and navigate to the properties section.
Scroll down to "Static website hosting."
c. To enable static hosting, click "Edit" in the top-right corner.
Choose the static host and specify the default homepage file (e.g., index.html).
Save changes.
Configure the bucket policy for public access by navigating to the bucket’s properties, select Permissions
, click on Bucket Policy,
and add the following policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadForGetBucketObjects",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::pmgoriya-day86/*"
}
]
}
Step 3: GitHub Actions Setup
Open your GitHub repository and navigate to Actions. Choose "set up a workflow yourself."
Step 4: Create main.yml Workflow File
a. Create a file named main.yml responsible for CI/CD operations.
name: Portfolio Deployment
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1
- name: Deploy static site to S3 bucket
run: aws s3 sync . s3://pmgoriya-day86 --delete
b. Explanation: Describes the workflow, triggers, and job details.
Step 5: AWS Credentials Setup
Configure AWS credentials by creating a new IAM User with Access Key and Secret Key.
Add these keys as secrets in the GitHub repository under Settings > Security > Secrets and variables > Actions.
Step 6: Application Deployment
Verify your configuration by checking for a green tick.
Access the deployed application by navigating to the S3 bucket's Permissions > Static website hosting, copying the URL, and opening it in your browser.
Final Deployment and CI/CD Experience
Your application is now deployed.
To experience CI/CD, commit changes to the main branch in your GitHub repository. The CI/CD pipeline will automatically start, deploying your application with the changes.
Thanks for following the project. See you in the next one.