Skip to content

Commit 86e4118

Browse files
committed
feat: Adds Build and push image to docker hub via CI pipline
1 parent 4314395 commit 86e4118

1 file changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
pull_request:
77

88
jobs:
9-
build:
9+
build-and-push:
1010
runs-on: ubuntu-latest
1111

1212
steps:
@@ -18,26 +18,30 @@ jobs:
1818
with:
1919
python-version: "3.11"
2020

21-
# 🔹 Cache pip downloads (speed boost)
2221
- name: Cache pip
2322
uses: actions/cache@v4
2423
with:
2524
path: ~/.cache/pip
2625
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
27-
restore-keys: |
28-
${{ runner.os }}-pip-
2926

3027
- name: Install dependencies
3128
run: |
3229
pip install -r requirements.txt
3330
34-
- name: Run app import check
31+
- name: Import check
3532
run: |
3633
python -c "import main"
3734
3835
- name: Set up Docker Buildx
3936
uses: docker/setup-buildx-action@v3
4037

41-
- name: Build Docker image
38+
- name: Login 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 image
4245
run: |
43-
docker build -t fastapi-app .
46+
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/fastapi-app:latest .
47+
docker push ${{ secrets.DOCKERHUB_USERNAME }}/fastapi-app:latest

0 commit comments

Comments
 (0)