forked from AdanRuiz/oci_devops_project
-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (47 loc) · 1.72 KB
/
Copy pathcd.yaml
File metadata and controls
55 lines (47 loc) · 1.72 KB
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
name: CD
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [master]
env:
OCIR_REGISTRY: mx-queretaro-1.ocir.io
IMAGE_REPOSITORY: mx-queretaro-1.ocir.io/axjlbcwfm44q/reacttodo/wx7u0/todolistapp-springboot
K8S_NAMESPACE: mtdrworkshop
K8S_DEPLOYMENT: todolistapp-springboot-deployment
K8S_CONTAINER: todolistapp-springboot
jobs:
deploy:
name: Deploy to OCI (OKE)
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success'
concurrency:
group: production-deploy
cancel-in-progress: false
environment: production
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Log in to OCIR
uses: docker/login-action@v3
with:
registry: ${{ env.OCIR_REGISTRY }}
username: ${{ secrets.OCIR_USERNAME }}
password: ${{ secrets.OCIR_PASSWORD }}
- name: Build and Push Docker image
run: |
IMAGE_TAG="${GITHUB_SHA:0:7}"
docker build -f MtdrSpring/backend/Dockerfile -t "$IMAGE_REPOSITORY:$IMAGE_TAG" MtdrSpring/backend/
docker push "$IMAGE_REPOSITORY:$IMAGE_TAG"
- name: Set up Kubernetes config
run: |
mkdir -p ~/.kube
echo "${{ secrets.KUBECONFIG_DATA }}" | base64 -d > ~/.kube/config
chmod 600 ~/.kube/config
- name: Deploy to Kubernetes (OKE)
run: |
IMAGE_TAG="${GITHUB_SHA:0:7}"
kubectl set image deployment/"$K8S_DEPLOYMENT" "$K8S_CONTAINER"="$IMAGE_REPOSITORY":"$IMAGE_TAG" -n "$K8S_NAMESPACE"
kubectl rollout status deployment/"$K8S_DEPLOYMENT" -n "$K8S_NAMESPACE" --timeout=180s
kubectl get pods -n "$K8S_NAMESPACE"