Skip to content

Commit e890e0e

Browse files
committed
pipelines
1 parent db4c20d commit e890e0e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/ci-cd.yml

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
- main # Trigger on pushes to the main branch
7+
pull_request:
8+
branches:
9+
- main # Trigger on pull requests to the main branch
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v3
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v4
21+
with:
22+
python-version: '3.9'
23+
24+
- name: Build Docker image
25+
run: docker build -t my-app .
26+
27+
- name: Run tests
28+
run: |
29+
docker run --rm my-app python -m unittest discover -s tests
30+
31+
deploy:
32+
needs: build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: Checkout code
36+
uses: actions/checkout@v3
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v2
40+
41+
- name: Log in to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKER_USERNAME }}
45+
password: ${{ secrets.DOCKER_PASSWORD }}
46+
47+
- name: Build and push Docker image
48+
run: |
49+
docker build -t ${{ secrets.DOCKER_USERNAME }}/my-app:latest .
50+
docker push ${{ secrets.DOCKER_USERNAME }}/my-app:latest

0 commit comments

Comments
 (0)