Skip to content

Commit d1579a9

Browse files
changes to deploy
1 parent 5b6dc87 commit d1579a9

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
CLUSTER_NAME: ${{ secrets.CLUSTER_NAME }}
1818
IMAGE_NAME: codeval
1919
DOCKERFILE: Dockerfile
20+
K8S_NAMESPACE: default
21+
DEPLOYMENT_NAME: codeeval
22+
CONTAINER_NAME: codeeval
2023

2124
steps:
2225
- name: Checkout code
@@ -49,4 +52,20 @@ jobs:
4952
-t "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tag }}" .
5053
5154
- name: Push image
52-
run: docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tag }}"
55+
run: docker push "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tag }}"
56+
57+
# - name: Tag on GitHub for backup (optional)
58+
# if: github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/main'
59+
# run: |
60+
# git tag "${{ matrix.image_name }}-${{ steps.meta.outputs.tag }}" || true
61+
# git push origin "${{ matrix.image_name }}-${{ steps.meta.outputs.tag }}" || true
62+
63+
- name: Save kubeconfig with short-lived credentials
64+
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 "${{ env.CLUSTER_NAME }}"
65+
66+
- name: Set image in Kubernetes
67+
run: |
68+
kubectl -n "${{ env.K8S_NAMESPACE }}" set image deployment/${{ env.DEPLOYMENT_NAME }} \
69+
${{ env.CONTAINER_NAME }}=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.tag }} \
70+
--record
71+
kubectl -n "${{ env.K8S_NAMESPACE }}" rollout status deployment/${{ env.DEPLOYMENT_NAME }} --timeout=120s

0 commit comments

Comments
 (0)