Skip to content

Commit

Permalink
configured github workflows for ci/cd using github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ari-o12code committed Aug 16, 2024
1 parent b59ea21 commit c2cfd95
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 0 deletions.
65 changes: 65 additions & 0 deletions .github/workflows/kubernetes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# This is a basic workflow to help you get started with Actions
#
name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- 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: ${{ vars.REGION }}

- name: Install kubectl
uses: azure/setup-kubectl@v3

- name: Install helm
uses: azure/setup-helm@v4.2.0

- name: Update kubeconfig
run: |
aws eks update-kubeconfig --region us-east-1 --name alameen-eks-cluster
kubectl config set-context --current --namespace=sock-shop
kubectl apply -f https://github.com/jetstack/cert-manager/releases/download/v1.5.3/cert-manager.crds.yaml
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.15.1/cert-manager.yaml
- name: add helm charts
run: |
helm repo add ingress https://kubernetes.github.io/ingress-nginx
helm repo add prometheus https://prometheus-community.github.io/helm-charts
- name: Update helm charts
run: helm repo update

- name: install helm charts
run: |
helm upgrade --install prometheus prometheus/kube-prometheus-stack
helm upgrade --install ingress ingress/ingress-nginx
- name: run manifest files
run: kubectl apply -f kubernetes/.
58 changes: 58 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# This is a basic workflow to help you get started with Actions

name: terraform

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "terraform" ]


# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4

- 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: ${{ vars.REGION }}


- name: Create s3 bucket
run: aws s3 mb s3://sockshop-terraform-state-bucket

- name: Install kubectl
uses: azure/setup-kubectl@v3

- name: Install helm
uses: azure/setup-helm@v4.2.0


- name: setup terraform
uses: hashicorp/setup-terraform@v2

- name: Create EKS cluster
run: |
terraform -chdir=terraform/ init
terraform -chdir=terraform apply --auto-approve
- name: Update kubeconfig
run: |
aws eks update-kubeconfig --region us-east-1 --name alameen-eks-cluster
kubectl create namespace sock-shop

0 comments on commit c2cfd95

Please sign in to comment.