71
71
echo "stage=dev" >> $GITHUB_ENV
72
72
fi
73
73
74
+ - name : Check for Changes
75
+ id : find_changes
76
+ run : |
77
+ if [ -z "$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} -- app)" ]; then
78
+ echo "::set-output name=deploy::false"
79
+ else
80
+ echo "::set-output name=deploy::true"
81
+ fi
82
+
74
83
- name : Build, tag, and push image to Amazon ECR
75
84
id : build-push-image
76
85
uses : ./.github/actions/build-push-image
@@ -81,29 +90,41 @@ jobs:
81
90
ecr-repository : ${{ env.ECR_REPOSITORY }}
82
91
dockerfile : ./Dockerfile
83
92
stage : ${{ env.stage }}
93
+ buildable : ${{ steps.find_changes.outputs.deploy }}
84
94
85
95
- name : Update Kubeconfig
86
- run : aws eks update-kubeconfig --name ${{ env.EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }}
96
+ run : |
97
+ if [ "${{ steps.find_changes.outputs.deploy }}" != "false" ]; then
98
+ aws eks update-kubeconfig --name ${{ env.EKS_CLUSTER_NAME }} --region ${{ env.AWS_REGION }}
99
+ fi
87
100
88
101
- name : Deploy to EKS
89
102
working-directory : ./k8s
90
103
env :
91
104
IMAGE : ${{ steps.build-push-image.outputs.image }}
92
105
STAGE : ${{ env.stage }}
93
106
run : |
94
- sed -i "s|{{IMAGE}}|${IMAGE}|g" ${STAGE}/deployment.yaml
95
- kubectl apply -f ${STAGE}
107
+ if [ "${{ steps.find_changes.outputs.deploy }}" != "false" ]; then
108
+ sed -i "s|{{IMAGE}}|${IMAGE}|g" ${STAGE}/deployment.yaml
109
+ kubectl apply -f ${STAGE}
110
+ fi
96
111
97
112
- name : Verify Deployment
98
113
id : verify-deployment
114
+ env :
115
+ STAGE : ${{ env.stage }}
99
116
shell : bash
100
117
run : |
101
- kubectl rollout status deployment/app -n ${STAGE} --timeout=5m
102
- if [ $? -eq 0 ]; then
103
- echo "status=Deployment successful!" >> $GITHUB_OUTPUT
118
+ if [ "${{ steps.find_changes.outputs.deploy }}" != "false" ]; then
119
+ kubectl rollout status deployment/app -n ${STAGE} --timeout=5m
120
+ if [ $? -eq 0 ]; then
121
+ echo "status=Deployment successful!" >> $GITHUB_OUTPUT
122
+ else
123
+ echo "status=Deployment failed!" >> $GITHUB_OUTPUT
124
+ exit 1
125
+ fi
104
126
else
105
- echo "status=Deployment failed!" >> $GITHUB_OUTPUT
106
- exit 1
127
+ echo "status=No changes to deploy" >> $GITHUB_OUTPUT
107
128
fi
108
129
109
130
notify-slack :
0 commit comments