Automate, customize and execute your software development workflows in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a customized workflow.
- GitHub Actions
- Identity and Access Management (IAM) for creating Service Role
- Amazon S3
- Create a repository
- Clone the repository on the local IDE
- Create a html file a write simple content.
- Folder structure like this
- Push this code on the GitHub repository.
- Create a S3 Bucket
- Gives all public assecc.
- Go to the properties in the bucket -> Static website hosting -> Click Edit -> Enable
- Go to the permissions section in the bucket -> Bucket policy -> Edit -> Add this policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::portfolio-aws-github-action/*"
}
]
}
After looking like this (repo_name)/.github/workflows/main.yml
- Write a workflow in
main.yml
name: 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://portfolio-aws-github-action --delete
- Go to the repository Settings
- Click on
secrets and variables
->Actions
- After Click on New repository secret -> Name*
AWS_ACCESS_KEY_ID
-> Secret*Add AWS IAM user
Access key` - One's again click on New repository secret -> Name*
AWS_SECRET_ACCESS_KEY
-> Secret*Add AWS IAM user
Secret access key`
- After Committing this all changes and see this.