Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 10m42s
63 lines
2.0 KiB
YAML
63 lines
2.0 KiB
YAML
name: Build and Deploy Backend
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build-and-deploy:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Restore kubeconfig
|
|
run: |
|
|
mkdir -p ~/.kube
|
|
echo $KUBECONFIG_DATA | base64 -d > ~/.kube/config
|
|
chmod 600 ~/.kube/config
|
|
env:
|
|
KUBECONFIG_DATA: ${{ secrets.KUBECONFIG }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install kubectl
|
|
run: |
|
|
curl -LO "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
|
|
chmod +x kubectl
|
|
sudo mv kubectl /usr/local/bin/kubectl
|
|
|
|
- name: Build & Deploy with Kaniko (all in one)
|
|
run: |
|
|
/usr/local/bin/kubectl apply -f - <<EOJOB
|
|
apiVersion: batch/v1
|
|
kind: Job
|
|
metadata:
|
|
name: build-backend-${GITHUB_SHA:0:8}
|
|
namespace: cloudforge
|
|
spec:
|
|
ttlSecondsAfterFinished: 600
|
|
template:
|
|
spec:
|
|
containers:
|
|
- name: kaniko
|
|
image: gcr.io/kaniko-project/executor:v1.9.0
|
|
args:
|
|
- "--dockerfile=Dockerfile"
|
|
- "--context=git://gitea-http.gitea.svc.cluster.local:3000/cloudforge-dev/dashboard-backend.git#main"
|
|
- "--destination=cloudforge-dashboard-backend:${GITHUB_SHA:0:8}"
|
|
- "--destination=cloudforge-dashboard-backend:latest"
|
|
- "--insecure"
|
|
- "--skip-tls-verify"
|
|
- "--no-push"
|
|
restartPolicy: Never
|
|
EOJOB
|
|
|
|
/usr/local/bin/kubectl wait --for=condition=complete --timeout=600s job/build-backend-${GITHUB_SHA:0:8} -n cloudforge
|
|
|
|
/usr/local/bin/kubectl set image deployment/dashboard-backend backend=cloudforge-dashboard-backend:${GITHUB_SHA:0:8} -n cloudforge --record
|
|
|
|
/usr/local/bin/kubectl rollout status deployment/dashboard-backend -n cloudforge --timeout=300s
|
|
|
|
/usr/local/bin/kubectl delete job build-backend-${GITHUB_SHA:0:8} -n cloudforge
|