Skip to content

Commit

Permalink
Create eks-pratham-deployment.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhilashKD authored May 31, 2024
1 parent 0d8bb93 commit 50f670c
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/eks-pratham-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Deploy to EKS-Pratham-Attendance Service
on:
push:
branches:
- main
env:
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME }}
AWS_REGION: ${{ secrets.AWS_REGION_NAME }}

jobs:

build:

name: Deployment
runs-on: ubuntu-latest

steps:
- name: Set short git commit SHA
id: commit
uses: prompt/actions-commit-hash@v2

- name: Check out code
uses: actions/checkout@v2

- 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: ${{env.AWS_REGION}}

- name: Setup Node Env
uses: actions/setup-node@v3
with:
node-version: 21.1.0

- name: Copy .env file
env:
ENV_FILE_CONTENT: ${{ secrets.ENV_FILE_CONTENT }}
run: echo "$ENV_FILE_CONTENT" > .env

- name: Show PWD and list content
run: |
echo "Current Working Directory: pwd"
pwd
ls -ltra
- name: Creating Dockerfile
env:
DOCKERFILE_FILE_CONTENT: ${{ secrets.DOCKERFILE_FILE_CONTENT }}
run: echo "$DOCKERFILE_FILE_CONTENT" > Dockerfile

- name: Show PWD and list content
run: |
echo "Current Working Directory: pwd"
pwd
ls -ltra
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1

- name: Build, tag, and push image to Amazon ECR
run: |
aws ecr --region ${{ secrets.AWS_REGION_NAME }} | docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }} .
docker push ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG }}
- name: Update kube config
run: aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }} --region ${{ secrets.AWS_REGION_NAME }}

- name: Deploy to EKS
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ secrets.IMAGE_TAG }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
ECR_IMAGE: ${{ secrets.ECR_IMAGE }}
run: |
export ECR_REPOSITORY=${{ secrets.ECR_REPOSITORY }}
export IMAGE_TAG=${{ secrets.IMAGE_TAG }}
export ECR_IMAGE=${{ secrets.ECR_IMAGE }}
envsubst < manifest/attendance-service.yaml > manifest/attendance-service-updated.yaml
cat manifest/attendance-service-updated.yaml
kubectl apply -f manifest/attendance-service-updated.yaml

0 comments on commit 50f670c

Please sign in to comment.