Skip to content

Commit 8423b84

Browse files
Update ci-api.yml
1 parent 4f43530 commit 8423b84

1 file changed

Lines changed: 0 additions & 92 deletions

File tree

.github/workflows/ci-api.yml

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1 @@
1-
name: CI — API Service
21

3-
on:
4-
push:
5-
branches: [main]
6-
pull_request:
7-
branches: [main]
8-
9-
env:
10-
REGISTRY: ghcr.io
11-
IMAGE_NAME: ${{ github.repository }}/api
12-
13-
jobs:
14-
lint:
15-
name: Lint & Import Check (API)
16-
runs-on: ubuntu-latest
17-
steps:
18-
- name: Checkout code
19-
uses: actions/checkout@v4
20-
21-
- name: Set up Python
22-
uses: actions/setup-python@v5
23-
with:
24-
python-version: "3.11"
25-
cache: "pip"
26-
27-
- name: Install lint dependencies
28-
run: |
29-
pip install flake8 black isort
30-
# Install project deps if requirements exist
31-
[ -f api/requirements.txt ] && pip install -r api/requirements.txt || true
32-
33-
- name: Black formatting check
34-
run: black --check api/
35-
36-
- name: isort import order check
37-
run: isort --check-only api/
38-
39-
- name: Flake8 lint
40-
run: flake8 api/ --max-line-length=100 --ignore=E203,W503
41-
42-
- name: Python import check (catch broken imports)
43-
run: |
44-
cd api
45-
python -c "import ast, sys, pathlib
46-
errors = []
47-
for f in pathlib.Path('.').rglob('*.py'):
48-
try:
49-
ast.parse(f.read_text())
50-
except SyntaxError as e:
51-
errors.append(f'{f}: {e}')
52-
if errors:
53-
print('\n'.join(errors)); sys.exit(1)
54-
print('All Python files parsed OK')"
55-
56-
build-and-push:
57-
name: Build & Push API Image
58-
runs-on: ubuntu-latest
59-
needs: lint
60-
permissions:
61-
contents: read
62-
packages: write
63-
64-
steps:
65-
- name: Checkout code
66-
uses: actions/checkout@v4
67-
68-
- name: Log in to GitHub Container Registry
69-
uses: docker/login-action@v3
70-
with:
71-
registry: ${{ env.REGISTRY }}
72-
username: ${{ github.actor }}
73-
password: ${{ secrets.GITHUB_TOKEN }}
74-
75-
- name: Extract Docker metadata
76-
id: meta
77-
uses: docker/metadata-action@v5
78-
with:
79-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
80-
tags: |
81-
type=sha,prefix=sha-
82-
type=raw,value=latest,enable={{is_default_branch}}
83-
84-
- name: Build and push API Docker image
85-
uses: docker/build-push-action@v5
86-
with:
87-
context: .
88-
file: Dockerfile.api
89-
push: ${{ github.ref == 'refs/heads/main' }}
90-
tags: ${{ steps.meta.outputs.tags }}
91-
labels: ${{ steps.meta.outputs.labels }}
92-
cache-from: type=gha
93-
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)