Added CI CD with Github actions, base CI CD #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --legacy-peer-deps | |
- 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 |