-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (64 loc) · 1.84 KB
/
ci.yml
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
name: CI
on:
push:
branches:
- main
pull_request:
env:
POETRY_VERSION: 1.7.1
GHCR_IMAGE_REPOSITORY: ghcr.io/${{ github.repository_owner }}/poetry
PLATFORMS: linux/amd64,linux/arm64/v8
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python:
- "3.8"
- "3.9"
- "3.10"
- "3.11"
- "3.12"
variant:
- bookworm
- slim
steps:
- uses: actions/checkout@v4.1.1
- name: Build Docker Image
uses: docker/build-push-action@v5.1.0
with:
context: .
push: false
tags: test-image
target: test
build-args: POETRY_VERSION=${{ env.POETRY_VERSION }}
- name: Run Tests in Docker
run: |
docker run --rm \
-e POETRY_VERSION=${{ env.POETRY_VERSION }} \
test-image python3 /usr/src/app/tests.py
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up multiplatform builds
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ env.PLATFORMS }}
- name: Set up buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Docker Image
uses: docker/build-push-action@v5.1.0
with:
context: .
push: true
tags: ${{ env.GHCR_IMAGE_REPOSITORY }}:${{ github.sha }}-${{ matrix.python }}-${{ matrix.variant }}
platforms: ${{ env.PLATFORMS }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
POETRY_VERSION=${{ env.POETRY_VERSION }}
PYTHON_VERSION=${{ matrix.python }}
VARIANT=${{ matrix.variant }}