feat: initial commit project sidata
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
name: CI/CD Pipeline to Rancher - SIDATA
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
|
||||
jobs:
|
||||
build-and-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Login ke Registry Gitea Lokal
|
||||
- name: Log in to Gitea Container Registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: 10.15.39.187:3000
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||
|
||||
# Build & Push Image Aplikasi SIDATA ke Registry
|
||||
- name: Build and Push Docker Image
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
tags: |
|
||||
10.15.39.187:3000/${{ secrets.REGISTRY_USER }}/sidata:latest
|
||||
10.15.39.187:3000/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }}
|
||||
|
||||
# Deploy & Update Workload di Cluster Local Rancher BPKD
|
||||
- name: Deploy to Rancher Cluster
|
||||
run: |
|
||||
# Download binary kubectl
|
||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
||||
chmod +x kubectl
|
||||
|
||||
# Set Kubeconfig menggunakan API Rancher BPKD
|
||||
./kubectl config set-cluster rancher-cluster --server=${{ secrets.RANCHER_URL }}/k8s/clusters/${{ secrets.RANCHER_CLUSTER_ID }} --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
|
||||
|
||||
# Update Container Image untuk Workload sidata
|
||||
# Sesuaikan 'sidata-deployment', 'sidata-container', dan namespace jika berbeda di Rancher
|
||||
./kubectl set image deployment/sidata-deployment sidata-container=10.15.39.187:3000/${{ secrets.REGISTRY_USER }}/sidata:${{ gitea.sha }} -n sidataprod
|
||||
|
||||
# Pantau Status Rollout hingga Sukses
|
||||
./kubectl rollout status deployment/sidata-deployment -n sidataprod
|
||||
Reference in New Issue
Block a user