-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (98 loc) · 3.16 KB
/
github-actions.yml
File metadata and controls
111 lines (98 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# GitHub Actions Workflow for CI/CD Pipeline
# This workflow automates testing, building, and deployment of microservices
#
# Triggers:
# - Push events to main branch
#
# Key Components:
# 1. install-deps-and-test job:
# - Installs required tools (Kind, Istioctl, Kubectl)
# - Runs integration tests in Kind cluster
#
# 2. build-scan-and-publish job:
# - Runs after successful testing
# - Builds and publishes container images
#
# Environment:
# - Runs on latest Ubuntu runner
# - Uses actions/checkout@v3 for code access
#
# Tools Installed:
# - Kind: Local Kubernetes cluster
# - Istioctl: Service mesh management
# - Kubectl: Kubernetes CLI
#
# Testing:
# - Executes test-local.sh script
# - Verifies cluster setup and service health
#
# References:
# - GitHub Actions: https://docs.github.com/en/actions
# - Kind: https://kind.sigs.k8s.io/
# - Istio: https://istio.io/
# - Kubectl: https://kubernetes.io/docs/reference/kubectl/
name: Ecommerce Project CI/CD Pipeline
on:
push:
branches:
- main
jobs:
install-deps-and-test:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout Code
- uses: actions/checkout@v3
# Step 2: Install Kind
- name: Install Kind
run: |
curl -Lo ./kind-binary https://kind.sigs.k8s.io/dl/latest/kind-linux-amd64
chmod +x ./kind-binary
sudo mv ./kind-binary /usr/local/bin/kind
kind version
# Step 3: Install Istioctl
- name: Install Istioctl
run: |
curl -L https://istio.io/downloadIstioctl | sh -
sudo mv $HOME/.istioctl/bin/istioctl /usr/local/bin/istioctl
istioctl version
# Step 4: Install Kubectl
- name: Install Kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
# Step 5: Run Tests
- name: Test with Kind
run: |
chmod +x ./scripts/test-local.sh
./scripts/test-local.sh
build-scan-and-publish:
needs: install-deps-and-test
runs-on: ubuntu-latest
steps:
# Step 1: Checkout Code
- name: Checkout Code
uses: actions/checkout@v3
# Step 2: Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Step 3: Build Docker images
- name: Build Docker Images
run: |
for service in order catalog search frontend; do
docker build -t egitangu/$service-service:latest -f app/$service/Dockerfile app/$service
done
# Step 4: Push Docker images
- name: Push Docker Images
run: |
for service in order catalog search frontend; do
docker push egitangu/$service-service:latest
done
# Step 5: Vulnerability Scan (using one example image, can be extended)
- name: Vulnerability Scan
uses: aquasecurity/trivy-action@master
with:
image-ref: egitangu/order-service:latest