From ea6b08db6504b416685166243813f6b5e17cd2ac Mon Sep 17 00:00:00 2001 From: Robert Date: Wed, 18 Dec 2024 13:49:12 +0200 Subject: [PATCH] Added CI CD with Github actions, base CI CD --- .github/workflows/cicd.yml | 73 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 .github/workflows/cicd.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml new file mode 100644 index 0000000..4d86a24 --- /dev/null +++ b/.github/workflows/cicd.yml @@ -0,0 +1,73 @@ +name: CloudVault CI/CD + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + build-and-test-backend: + name: Build & Test Backend + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: 1.28 + + - name: Install Dependencies + run: go mod tidy + + - name: Run Tests + run: go test ./... -v + + build-and-test-frontend: + name: Build & Test Frontend + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + + - name: Install Dependencies + working-directory: ./frontend + run: npm install + + - name: Run Tests + working-directory: ./frontend + run: npm run test + + deploy: + name: Deploy to IBM Cloud + needs: [build-and-test-backend, build-and-test-frontend] + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Authenticate with IBM Cloud + run: | + echo "${{ secrets.IBM_CLOUD_API_KEY }}" | ibmcloud login --apikey @- + + - name: Configure Kubernetes Cluster + run: ibmcloud ks cluster config --cluster cloudvault-cluster + + - name: Deploy Backend to Kubernetes + run: | + kubectl apply -f k8s/backend-deployment.yml + kubectl apply -f k8s/backend-service.yml + + - name: Deploy Frontend to Kubernetes + run: | + kubectl apply -f k8s/frontend-deployment.yml + kubectl apply -f k8s/frontend-service.yml