Skip to content

Commit d7474c5

Browse files
Commit New Changes
1 parent 5d52c70 commit d7474c5

File tree

3 files changed

+61
-26
lines changed

3 files changed

+61
-26
lines changed

.github/workflows/ci-cd.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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

.github/workflows/ci.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Dockerfile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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"]

0 commit comments

Comments
 (0)