File tree Expand file tree Collapse file tree 3 files changed +61
-26
lines changed Expand file tree Collapse file tree 3 files changed +61
-26
lines changed Original file line number Diff line number Diff line change 1+ name : Python CI/CD Pipeline 
2+ 
3+ on :
4+   push :
5+     branches : [ main ] 
6+   pull_request :
7+     branches : [ main ] 
8+ 
9+ jobs :
10+   build :
11+     runs-on : ubuntu-latest 
12+     steps :
13+       - name : Checkout code 
14+         uses : actions/checkout@v3 
15+         
16+       - name : Set up Python 
17+         uses : actions/setup-python@v4 
18+         with :
19+           python-version : ' 3.x' 
20+           
21+       - name : Install dependencies 
22+         run : | 
23+           python -m pip install --upgrade pip 
24+           pip install -r requirements.txt 
25+            
26+ name : Run tests 
27+         run : | 
28+           pytest --maxfail=5 --disable-warnings 
29+ 
30+ deploy :
31+     needs : build 
32+     runs-on : ubuntu-latest 
33+     if : success()  #  Only run if tests pass
34+     steps :
35+       - name : Checkout code 
36+         uses : actions/checkout@v3 
37+         
38+       - name : Log in to Docker Hub 
39+         uses : docker/login-action@v3 
40+         with :
41+           username : ${{ secrets.DOCKERHUB_USERNAME }} 
42+           password : ${{ secrets.DOCKERHUB_TOKEN }} 
43+           
44+       - name : Build and push Docker image 
45+         uses : docker/build-push-action@v5 
46+         with :
47+           context : . 
48+           push : true 
49+           tags : ${{ secrets.DOCKERHUB_USERNAME }}/python-ci-demo:latest 
Load Diff This file was deleted. 
Original file line number Diff line number Diff line change 1+ #  Use Python base image
2+ FROM  python:3.10-slim
3+ #  Set working directory
4+ WORKDIR  /app
5+ #  Copy project files
6+ COPY  . /app
7+ #  Install dependencies
8+ RUN  pip install --no-cache-dir -r requirements.txt
9+ #  Expose default Flask port
10+ EXPOSE  5000
11+ #  Run the app
12+ CMD  ["python" , "app.py" ]
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments