What is CI/CD?
- CI --> Continuous Integration
- CD --> Continuous Deployment
Here, we will setup the CI/CD using GitHub Actions and deploy infrastructure on AWS
- Deployment
- Automation
Here are the steps for Setting up GitHub Actions for CI/CD :
-
Check the previous day documentations for the steps done till now regarding IAM, S3, CloudFormation, CloudFront, Certificate Manager, API GateWay and DynamoDB
-
Create a
.github
directory and inside that, createworkflows
directory -
Create
main.yaml
inside the above directory and use the following snippet:
(This configuration includes testing, build and deployment automations and Please make changes according to your naming conventions)
name: main
on: push
env:
GO_VERSION: 1.18.3
jobs:
build-infra:
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2.1.3
with:
go-version: ${{ env.GO_VERSION }}
- name: test get-function
run: cd get-function && go test -v ./ && cd ../../
- name: test put-function
run: cd put-function && go test -v ./ && cd ../../
build-and-deploy-infra:
needs: build-infra
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: aws-actions/setup-sam@v1
- 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
- run: sam build
working-directory: ./
- run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset
working-directory: ./
deploy-site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jakejarvis/s3-sync-action@master
with:
args: --delete
env:
AWS_S3_BUCKET: ronit-demo-site
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: ./resume-site
- Push this repository to GitHub and at first it will throw error. Because the Secrets are not stored in the github repository. Add the secrets to the repository as shown below:
Re-run the jobs from GitHub Actions
This time it will be successfully executed !
So, Finally the Cloud Resume Challenge comes to an end from Day-2
--> Day-10
Our end Product of the Project is https://ronitbanerjee.xyz
And here is the Codebase in GitHub Repository