Skip to content

Commit 681f25c

Browse files
committed
fix relative imports and separate publish and deploy workflows
1 parent c8cf01b commit 681f25c

5 files changed

Lines changed: 49 additions & 22 deletions

File tree

.github/workflows/deploy-to-lambda.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
name: Build Deployment Image
1+
name: Deploy to AWS Lambda
22
on:
33
push:
4-
tags:
5-
- "*"
4+
branches:
5+
- deploy
66

77
permissions:
88
contents: write
@@ -49,12 +49,6 @@ jobs:
4949
cp $build_file ${{ github.workspace }}/deploy.zip
5050
shell: bash
5151

52-
- name: Publish to Github
53-
uses: softprops/action-gh-release@v1
54-
if: startsWith(github.ref, 'refs/tags/')
55-
with:
56-
files: dist/*.zip
57-
5852
- name: Deploy to Lambda
5953
uses: appleboy/lambda-action@v0.1.9
6054
with:
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Publish to Github Releases
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
7+
permissions:
8+
contents: write
9+
packages: write
10+
11+
jobs:
12+
build-and-deploy:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.12.1"
22+
23+
- name: Install dependencies
24+
run: |
25+
python -m pip install --user pipx
26+
python -m pipx ensurepath
27+
pipx install hatch
28+
29+
- name: Build zip
30+
run: |
31+
hatch build
32+
shell: bash
33+
34+
- name: Publish to Github
35+
uses: softprops/action-gh-release@v1
36+
if: startsWith(github.ref, 'refs/tags/')
37+
with:
38+
files: dist/*

src/api/data/queries.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
1-
from datetime import UTC, datetime
2-
31
import logging
2+
from datetime import UTC, datetime
43

54
from bson import ObjectId
65
from bson.json_util import dumps
76

8-
from src.api.data.instance import (
9-
DEFAULT_LIMIT,
10-
DEFAULT_OFFSET,
11-
sneakers,
12-
db,
13-
)
14-
from src.api.data.models import Audience, SortKey, SortOrder
7+
from api.data.instance import DEFAULT_LIMIT, DEFAULT_OFFSET, db, sneakers
8+
from api.data.models import Audience, SortKey, SortOrder
159

1610

1711
def find_sneaker_by_id(id: str = ""):

src/api/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from fastapi import FastAPI
22
from mangum import Mangum
3-
from src.api.routes import auth, sneakers
43
from starlette.middleware.sessions import SessionMiddleware
54

5+
from api.routes import auth, sneakers
6+
67
app = FastAPI(
78
redoc_url=None,
89
responses={404: {"description": "Not found"}},

src/api/routes/sneakers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from fastapi import APIRouter, Query
44

5-
from src.api.data.instance import DEFAULT_LIMIT, DEFAULT_OFFSET
6-
from src.api.data.models import Audience, SortKey, SortOrder
7-
from src.api.data.queries import find_sneaker_by_id, find_sneaker_by_sku, find_sneakers
5+
from api.data.instance import DEFAULT_LIMIT, DEFAULT_OFFSET
6+
from api.data.models import Audience, SortKey, SortOrder
7+
from api.data.queries import find_sneaker_by_id, find_sneaker_by_sku, find_sneakers
88

99
router = APIRouter(
1010
prefix="/sneakers",

0 commit comments

Comments
 (0)