Skip to content

Merge pull request #14 from poojakarma/userid_variable_name_changes #34

Merge pull request #14 from poojakarma/userid_variable_name_changes

Merge pull request #14 from poojakarma/userid_variable_name_changes #34

name: Deploy to EKS-Pratham-ms
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: Decode and write .env file
# run: |
# echo "${{ secrets.ENV_FILE_CONTENT_DEV }}" | base64 -d > manifest/configmap.yaml
# echo "Contents of manifest/configmap.yaml:"
# cat manifest/configmap.yaml
- name: Copy .env file
env:
ENV_FILE_CONTENT: ${{ secrets.ENV_FILE_CONTENT_DEV }}
run: printf "%s" "$ENV_FILE_CONTENT" > manifest/configmap.yaml
- 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 manifest/
- 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: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ secrets.ECR_IMAGE_TAG }}
run: |
docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.ECR_IMAGE_TAG }} .
docker push ${{ secrets.ECR_REPOSITORY }}:${{ secrets.ECR_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: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ secrets.ECR_IMAGE_TAG }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
ECR_IMAGE: ${{ secrets.ECR_IMAGE }}
run: |
export ECR_REPOSITORY=${{ secrets.ECR_REPOSITORY }}
export IMAGE_TAG=${{ secrets.ECR_IMAGE_TAG }}
export ECR_IMAGE=${{ secrets.ECR_IMAGE }}
envsubst < manifest/notification-service.yaml > manifest/notification-service-updated.yaml
echo "Contents of manifest/notification-service-updated.yaml:"
cat manifest/notification-service-updated.yaml
echo "kubectl apply exit code: $?"
kubectl get cm
ls -ltra manifest/
kubectl delete deployment notification
kubectl delete svc notification
kubectl apply -f manifest/configmap.yaml
kubectl describe cm notification-service-config
kubectl apply -f manifest/notification-service-updated.yaml
sleep 5
kubectl get pods
kubectl get services
kubectl get deployment
# ls -ltra manifest/
# kubectl apply -f manifest/configmap.yaml
# kubectl apply -f manifest/notification-service-updated.yaml
# sleep 10
# kubectl get pods
# kubectl get services
# kubectl get deployment
#testing