Skip to content

Commit 4aad9ac

Browse files
author
Daniel Schlör
committed
docker
1 parent e8e9778 commit 4aad9ac

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Test and Publish
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
tags: [ 'v*' ]
7+
pull_request:
8+
branches: [ master ]
9+
10+
env:
11+
REGISTRY: ghcr.io
12+
IMAGE_NAME: ${{ github.repository }}
13+
14+
jobs:
15+
test:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install uv
21+
uses: astral-sh/setup-uv@v4
22+
with:
23+
version: "latest"
24+
25+
- name: Set up Python
26+
run: uv python install 3.11
27+
28+
- name: Install dependencies
29+
run: uv sync --extra test
30+
31+
- name: Run tests
32+
env:
33+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
34+
run: uv run pytest tests/
35+
36+
build-and-publish:
37+
needs: test
38+
runs-on: ubuntu-latest
39+
if: github.event_name == 'push'
40+
permissions:
41+
contents: read
42+
packages: write
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Log in to Container Registry
48+
uses: docker/login-action@v3
49+
with:
50+
registry: ${{ env.REGISTRY }}
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Extract metadata
55+
id: meta
56+
uses: docker/metadata-action@v5
57+
with:
58+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
59+
tags: |
60+
type=ref,event=branch
61+
type=semver,pattern={{version}}
62+
type=semver,pattern={{major}}.{{minor}}
63+
type=semver,pattern={{major}}
64+
type=raw,value=latest,enable={{is_default_branch}}
65+
66+
- name: Build and push Docker image
67+
uses: docker/build-push-action@v5
68+
with:
69+
context: .
70+
push: true
71+
tags: ${{ steps.meta.outputs.tags }}
72+
labels: ${{ steps.meta.outputs.labels }}
73+

0 commit comments

Comments
 (0)