Skip to content

Commit 683f5be

Browse files
committed
New github action for week3
1 parent 6c625b8 commit 683f5be

File tree

2 files changed

+90
-15
lines changed

2 files changed

+90
-15
lines changed

.github/workflows/docker-build-push.yml

Lines changed: 89 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ jobs:
1111
prepare:
1212
runs-on: ubuntu-latest
1313
outputs:
14-
directories: ${{ steps.filter.outputs.changes }}
14+
week3: ${{ steps.filter.outputs.week3 }}
15+
week4: ${{ steps.filter.outputs.week4 }}
16+
week5: ${{ steps.filter.outputs.week5 }}
1517
steps:
1618
- name: Checkout code
1719
uses: actions/checkout@v4
@@ -21,21 +23,94 @@ jobs:
2123
uses: dorny/paths-filter@v3
2224
with:
2325
filters: |
24-
week3: 'Learn/week3/**'
25-
week4: 'Learn/week4/**'
26-
week5: 'Learn/week5/**'
26+
week3:
27+
- 'Learn/week3/**'
28+
week4:
29+
- 'Learn/week4/**'
30+
week5:
31+
- 'Learn/week5/**'
2732
28-
docker-build-push:
33+
build-week3:
2934
needs: prepare
30-
if: needs.prepare.outputs.directories != '[]'
35+
if: needs.prepare.outputs.week3 == 'true'
3136
runs-on: ubuntu-latest
32-
strategy:
33-
matrix:
34-
directory: ${{ fromJson(needs.prepare.outputs.directories) }}
3537
permissions:
3638
contents: read
3739
packages: write
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
44+
- name: Set up Docker Buildx
45+
uses: docker/setup-buildx-action@v3
46+
47+
- name: Login to GitHub Container Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Lowercase repository owner
55+
id: prep
56+
run: |
57+
echo "OWNER_LOWERCASE=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT
58+
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
3859
60+
- name: Build and Push Week 3
61+
uses: docker/build-push-action@v6
62+
with:
63+
context: ./Learn/week3
64+
file: ./Learn/week3/Dockerfile
65+
push: true
66+
tags: |
67+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week3:${{ steps.prep.outputs.IMAGE_TAG }}
68+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week3:latest
69+
70+
build-week4:
71+
needs: prepare
72+
if: needs.prepare.outputs.week4 == 'true'
73+
runs-on: ubuntu-latest
74+
permissions:
75+
contents: read
76+
packages: write
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v4
80+
81+
- name: Set up Docker Buildx
82+
uses: docker/setup-buildx-action@v3
83+
84+
- name: Login to GitHub Container Registry
85+
uses: docker/login-action@v3
86+
with:
87+
registry: ghcr.io
88+
username: ${{ github.actor }}
89+
password: ${{ secrets.GITHUB_TOKEN }}
90+
91+
- name: Lowercase repository owner
92+
id: prep
93+
run: |
94+
echo "OWNER_LOWERCASE=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT
95+
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
96+
97+
- name: Build and Push Week 4
98+
uses: docker/build-push-action@v6
99+
with:
100+
context: ./Learn/week4
101+
file: ./Learn/week4/Dockerfile
102+
push: true
103+
tags: |
104+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week4:${{ steps.prep.outputs.IMAGE_TAG }}
105+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week4:latest
106+
107+
build-week5:
108+
needs: prepare
109+
if: needs.prepare.outputs.week5 == 'true'
110+
runs-on: ubuntu-latest
111+
permissions:
112+
contents: read
113+
packages: write
39114
steps:
40115
- name: Checkout code
41116
uses: actions/checkout@v4
@@ -56,12 +131,12 @@ jobs:
56131
echo "OWNER_LOWERCASE=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_OUTPUT
57132
echo "IMAGE_TAG=${GITHUB_SHA::7}" >> $GITHUB_OUTPUT
58133
59-
- name: Build and Push
134+
- name: Build and Push Week 5
60135
uses: docker/build-push-action@v6
61136
with:
62-
context: ./Learn/${{ matrix.directory }}
63-
file: ./Learn/${{ matrix.directory }}/Dockerfile
137+
context: ./Learn/week5
138+
file: ./Learn/week5/Dockerfile
64139
push: true
65140
tags: |
66-
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-${{ matrix.directory }}:${{ steps.prep.outputs.IMAGE_TAG }}
67-
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-${{ matrix.directory }}:latest
141+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week5:${{ steps.prep.outputs.IMAGE_TAG }}
142+
ghcr.io/${{ steps.prep.outputs.OWNER_LOWERCASE }}/playground-week5:latest

Learn/week4/post-pydantic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
In Week 3, you only used **GET** requests. Let's understand why we need other methods.
1616

17-
#### GET Requests (What You've Been Using)
17+
#### GET Requests (What You've Been Using)
1818

1919
```python
2020
@app.get("/users")

0 commit comments

Comments
 (0)