Introduction
CI/CD is a method to frequently deliver apps to customers by introducing automation into the stages of app development. The main concepts attributed to CI/CD are continuous integration, continuous delivery, and continuous deployment
Advantages of CI/CD are:
Faster delivery
Cost reduction
Easy to maintain
What are GitHub Actions?
GitHub Actions is a platform that automates the build, test, and deployment of software. But it doesn’t stop there: it allows you also to run any arbitrary code on your repository when a specific event happens.
A workflow is a configurable automated process that will run one or more jobs. Workflows are defined by a YAML file checked into your repository and will run when triggered by an event in your repository, or they can be triggered manually, or at a defined schedule.
Architecture
Creating S3 Bucket
You can use the AWS Management Console to create IAM users.
Sign in to the AWS Management Console and open the S3 Bucket Dashboard
Create Bucket and enter bucket name, and turn off block all public access and enable static website hosting
Writing workflow for GitHub Actions
Go to Actions tab in github repository
Create workflow
Below is the YAML code for workflow
name: Website Deployment on: push: branches: - main - development jobs: 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 }} - name: Deploy static site to S3 bucket run: aws s3 sync . s3://S3_BUCKET_NAME --delete
Setting up AWS with GitHub Actions
Go to IAM dashboard in AWS
Go to users for which you want to connect with github actions
Go to security credentials
Now create access key, select CLI
You will get access key and secret access key
Go to repository settings > Actions > Enter your credentials here