-
Notifications
You must be signed in to change notification settings - Fork 31
83 lines (77 loc) · 2.14 KB
/
Copy pathuser-service.yml
File metadata and controls
83 lines (77 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
name: user-service CI/CD
on:
push:
paths:
- "services/user-service/**"
- ".github/workflows/user-service.yml"
pull_request:
paths:
- "services/user-service/**"
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/gamehub-user-service
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/user-service
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install ruff mypy
- run: ruff check app/
- run: mypy app/ --ignore-missing-imports
test:
name: Test
runs-on: ubuntu-latest
defaults:
run:
working-directory: services/user-service
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip
- run: pip install -r requirements.txt
- name: Run tests
env:
DATABASE_URL: sqlite:///./test.db
run: pytest tests/ -v --tb=short
build-and-push:
name: Build & Push
runs-on: ubuntu-latest
needs: [lint, test]
if: github.ref == 'refs/heads/main' && hashFiles('services/user-service/Dockerfile') != ''
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,prefix=sha-
type=raw,value=latest,enable={{is_default_branch}}
- uses: docker/build-push-action@v5
with:
context: services/user-service
target: runtime
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max