1
+ name : CI/CD Pipeline
2
+
3
+ on :
4
+ push :
5
+ branches : [ main, master ]
6
+ paths-ignore :
7
+ - ' **/*.md'
8
+ - ' .gitignore'
9
+ pull_request :
10
+ branches : [ main, master ]
11
+
12
+ env :
13
+ DOCKER_USERNAME : tuandung12092002
14
+ SEARCH_SERVER_IMAGE : tuandung12092002/semantic-search-server
15
+ DEMO_APP_IMAGE : tuandung12092002/semantic-search-demo
16
+
17
+ jobs :
18
+ build-and-push :
19
+ runs-on : ubuntu-latest
20
+ steps :
21
+ - name : Checkout code
22
+ uses : actions/checkout@v3
23
+
24
+ - name : Set up Docker Buildx
25
+ uses : docker/setup-buildx-action@v2
26
+
27
+ - name : Login to Docker Hub
28
+ uses : docker/login-action@v2
29
+ with :
30
+ username : ${{ env.DOCKER_USERNAME }}
31
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
32
+
33
+ - name : Extract metadata for Search Server
34
+ id : meta-search
35
+ uses : docker/metadata-action@v4
36
+ with :
37
+ images : ${{ env.SEARCH_SERVER_IMAGE }}
38
+ tags : |
39
+ type=ref,event=branch
40
+ type=ref,event=pr
41
+ type=semver,pattern={{version}}
42
+ type=semver,pattern={{major}}.{{minor}}
43
+ type=sha,format=long
44
+
45
+ - name : Build and Push Search Server Image
46
+ uses : docker/build-push-action@v4
47
+ with :
48
+ context : .
49
+ file : ./docker/search_server.Dockerfile
50
+ push : true
51
+ tags : ${{ steps.meta-search.outputs.tags }}
52
+ labels : ${{ steps.meta-search.outputs.labels }}
53
+ cache-from : type=gha
54
+ cache-to : type=gha,mode=max
55
+
56
+ - name : Extract metadata for Demo App
57
+ id : meta-demo
58
+ uses : docker/metadata-action@v4
59
+ with :
60
+ images : ${{ env.DEMO_APP_IMAGE }}
61
+ tags : |
62
+ type=ref,event=branch
63
+ type=ref,event=pr
64
+ type=semver,pattern={{version}}
65
+ type=semver,pattern={{major}}.{{minor}}
66
+ type=sha,format=long
67
+
68
+ - name : Build and Push Demo App Image
69
+ uses : docker/build-push-action@v4
70
+ with :
71
+ context : .
72
+ file : ./docker/demo_app.Dockerfile
73
+ push : true
74
+ tags : ${{ steps.meta-demo.outputs.tags }}
75
+ labels : ${{ steps.meta-demo.outputs.labels }}
76
+ cache-from : type=gha
77
+ cache-to : type=gha,mode=max
78
+
79
+ test-deployment :
80
+ needs : build-and-push
81
+ runs-on : ubuntu-latest
82
+ steps :
83
+ - name : Checkout code
84
+ uses : actions/checkout@v3
85
+
86
+ - name : Set up Docker Buildx
87
+ uses : docker/setup-buildx-action@v2
88
+
89
+ - name : Create secrets directory
90
+ run : mkdir -p secrets
91
+
92
+ - name : Create OpenAI API key file
93
+ run : echo "${{ secrets.OPENAI_API_KEY }}" > secrets/openai_api_key.txt
94
+
95
+ - name : Create Weaviate API key file
96
+ run : echo "${{ secrets.WEAVIATE_API_KEY }}" > secrets/weaviate_api_key.txt
97
+
98
+ - name : Deploy application
99
+ run : |
100
+ docker-compose -f docker/docker-compose.full.yml up -d
101
+
102
+ - name : Wait for services to start
103
+ run : |
104
+ sleep 30
105
+ docker-compose -f docker/docker-compose.full.yml ps
106
+
107
+ - name : Test Search API
108
+ run : |
109
+ # Wait for the API to be ready
110
+ sleep 10
111
+ curl -X POST http://localhost:8000/process-text \
112
+ -H "Content-Type: application/json" \
113
+ -d '{"text": "This is a test document for CI/CD pipeline."}'
114
+
115
+ curl -X POST http://localhost:8000/ask-question \
116
+ -H "Content-Type: application/json" \
117
+ -d '{"question": "What is semantic search?", "num_search_results": 3, "num_generations": 1}'
118
+
119
+ - name : Cleanup
120
+ if : always()
121
+ run : docker-compose -f docker/docker-compose.full.yml down
0 commit comments