ci: trigger build
This commit is contained in:
@@ -1,98 +1,70 @@
|
|||||||
name: CI/CD Pipeline to Rancher - SIDATA
|
name: CI/CD Pipeline to Rancher - SIDATA
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
# ============================================================
|
||||||
uses: actions/checkout@v3
|
# Checkout
|
||||||
|
# ============================================================
|
||||||
|
- name: Checkout Code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Login ke Gitea Container Registry
|
# ============================================================
|
||||||
- name: Log in to Gitea Container Registry
|
# Login Registry
|
||||||
uses: docker/login-action@v2
|
# ============================================================
|
||||||
with:
|
- name: Log in to Gitea Container Registry
|
||||||
registry: registry-bpkd.drc-bpkd.data-center.id
|
uses: docker/login-action@v2
|
||||||
username: ${{ secrets.REGISTRY_USER }}
|
with:
|
||||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
registry: registry-bpkd.drc-bpkd.data-center.id
|
||||||
|
username: ${{ secrets.REGISTRY_USER }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
|
||||||
|
# ============================================================
|
||||||
|
# Build & Push
|
||||||
|
# ============================================================
|
||||||
|
- name: Build and Push Docker Image
|
||||||
|
uses: docker/build-push-action@v4
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:latest
|
||||||
|
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}
|
||||||
|
|
||||||
# Build & Push Image SIDATA ke Gitea Registry
|
# ============================================================
|
||||||
- name: Build and Push Docker Image
|
# Deploy ke Rancher
|
||||||
uses: docker/build-push-action@v4
|
# ============================================================
|
||||||
with:
|
- name: Deploy to Rancher Cluster
|
||||||
context: .
|
shell: bash
|
||||||
push: true
|
run: |
|
||||||
tags: |
|
set -e
|
||||||
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:latest
|
|
||||||
registry-bpkd.drc-bpkd.data-center.id/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}
|
|
||||||
|
|
||||||
# Deploy ke Rancher
|
echo "=== Download kubectl ==="
|
||||||
- name: Deploy to Rancher Cluster
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "=== Download kubectl ==="
|
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
|
||||||
|
|
||||||
KUBECTL_VERSION=$(curl -L -s https://dl.k8s.io/release/stable.txt)
|
curl -fLO \
|
||||||
|
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
|
||||||
|
|
||||||
curl -fLO \
|
chmod +x kubectl
|
||||||
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
|
|
||||||
|
|
||||||
chmod +x kubectl
|
echo "kubectl version:"
|
||||||
|
./kubectl version --client
|
||||||
|
|
||||||
echo "kubectl version:"
|
echo "=== Configure Rancher Kubeconfig ==="
|
||||||
./kubectl version --client
|
|
||||||
|
|
||||||
echo "=== Configure Rancher Kubeconfig ==="
|
./kubectl config set-cluster rancher-cluster \
|
||||||
|
--server="${{ secrets.RANCHER_URL }}/k8s/clusters/${{ secrets.RANCHER_CLUSTER_ID }}" \
|
||||||
|
--insecure-skip-tls-verify=true
|
||||||
|
|
||||||
./kubectl config set-cluster rancher-cluster \
|
./kubectl config set-credentials rancher-user \
|
||||||
--server="${{ secrets.RANCHER_URL }}/k8s/clusters/${{ secrets.RANCHER_CLUSTER_ID }}" \
|
--token="${{ secrets.RANCHER_TOKEN }}"
|
||||||
--insecure-skip-tls-verify=true
|
|
||||||
|
|
||||||
./kubectl config set-credentials rancher-user \
|
./
|
||||||
--token="${{ secrets.RANCHER_TOKEN }}"
|
|
||||||
|
|
||||||
./kubectl config set-context rancher-context \
|
|
||||||
--cluster=rancher-cluster \
|
|
||||||
--user=rancher-user
|
|
||||||
|
|
||||||
./kubectl config use-context rancher-context
|
|
||||||
|
|
||||||
echo "=== Check Cluster ==="
|
|
||||||
|
|
||||||
./kubectl cluster-info
|
|
||||||
|
|
||||||
echo "=== Check SIDATA Deployment ==="
|
|
||||||
|
|
||||||
./kubectl get deployment -n sidata-prod
|
|
||||||
|
|
||||||
echo "=== Update SIDATA Image ==="
|
|
||||||
|
|
||||||
IMAGE="10.15.39.187:3000/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}"
|
|
||||||
|
|
||||||
echo "Deploy image: ${IMAGE}"
|
|
||||||
|
|
||||||
./kubectl set image \
|
|
||||||
deployment/sidata \
|
|
||||||
sidata="${IMAGE}" \
|
|
||||||
-n sidata-prod
|
|
||||||
|
|
||||||
echo "=== Wait Rollout ==="
|
|
||||||
|
|
||||||
./kubectl rollout status \
|
|
||||||
deployment/sidata \
|
|
||||||
-n sidata-prod \
|
|
||||||
--timeout=10m
|
|
||||||
|
|
||||||
echo "=== Deployment Status ==="
|
|
||||||
|
|
||||||
./kubectl get deployment sidata -n sidata-prod
|
|
||||||
|
|
||||||
./kubectl get pods -n sidata-prod -l app=sidata
|
|
||||||
Reference in New Issue
Block a user