-
Notifications
You must be signed in to change notification settings - Fork 8
91 lines (91 loc) · 3.45 KB
/
dev-deployment.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: Deploy to EKS-Pratham
on:
workflow_dispatch:
env:
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
EKS_CLUSTER_NAME: ${{ secrets.EKS_CLUSTER_NAME_DEV }}
AWS_REGION: ${{ secrets.AWS_REGION_NAME }}
jobs:
build_dev:
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
with:
fetch-depth: 0
- 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_DEV }}
run: printf "%s" "$ENV_FILE_CONTENT" > manifest/configmap.yaml
# run: echo "$ENV_FILE_CONTENT" > manifest/configmap.yaml
- name: Copy .env file in the code
env:
DEV_ENV: ${{ secrets.DEV_ENV }}
run: rm -f .env && echo '${{ secrets.DEV_ENV }}' > .env
#echo "$ENV_FILE_CONTENT" > manifest/configmap.yaml
- name: Show PWD and list content and Latest 3 commits
run: |
echo "Fetching all branches to ensure complete history"
git fetch --all
echo "Checking out the current branch"
git checkout ${{ github.ref_name }}
echo "Git Branch cloned"
git branch
echo "Current 3 merge commits are:"
git log --merges -n 3
pwd
ls -ltra
- 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 }}
run: |
docker build -t ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG_DEV }} .
docker push ${{ secrets.ECR_REPOSITORY }}:${{ secrets.IMAGE_TAG_DEV }}
- name: Update kube config
run: aws eks update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME_DEV }} --region ${{ secrets.AWS_REGION_NAME }}
- name: Deploy to EKS
env:
ECR_REGISTRY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ secrets.IMAGE_TAG_DEV }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
ECR_IMAGE: ${{ secrets.ECR_IMAGE_DEV }}
run: |
export ECR_REPOSITORY=${{ secrets.ECR_REPOSITORY }}
export IMAGE_TAG=${{ secrets.IMAGE_TAG_DEV }}
export ECR_IMAGE=${{ secrets.ECR_IMAGE_DEV }}
envsubst < manifest/workspace.yaml > manifest/workspace-updated.yaml
cat manifest/workspace-updated.yaml
rm -rf manifest/workspace-service.yaml
kubectl delete deployment shiksha-workspace
kubectl delete service shiksha-workspace
kubectl delete cm workspace-service-config
kubectl apply -f manifest/workspace-updated.yaml
kubectl apply -f manifest/configmap.yaml
sleep 10
kubectl get pods
kubectl get services
kubectl get deployment