diff --git a/.gitea/workflows/deploy.yaml b/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..f8334c4 --- /dev/null +++ b/.gitea/workflows/deploy.yaml @@ -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 \ No newline at end of file diff --git a/.gitignore copy b/.gitignore copy new file mode 100644 index 0000000..bdf132b --- /dev/null +++ b/.gitignore copy @@ -0,0 +1,16 @@ +/node_modules +/public/hot +/public/storage +/public/uploadFiles +/public/downloadFiles +/storage/*.key +.env +.env.backup +.phpunit.result.cache +docker-compose.override.yml +Homestead.json +Homestead.yaml +npm-debug.log +yarn-error.log +/.idea +/.vscode