Repository navigation
86 lines (75 loc) · 2.68 KB
/
Copy pathdocker.yml
File metadata and controls
86 lines (75 loc) · 2.68 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
83
84
85
86
name: Docker
on:
push:
branches: [master]
pull_request:
schedule:
# Weekly rebuild to pick up patched base images
- cron: "0 4 * * 1"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE: tecktron/python-bjoern
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.11", "3.12", "3.13", "3.14", "latest"]
variant: ["", "-slim"]
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Resolve base image and tag
id: vars
env:
PY: ${{ matrix.python }}
VARIANT: ${{ matrix.variant }}
run: |
if [ "$PY" = "latest" ]; then
# Floating tags: python:latest -> latest, python:slim -> latest-slim
base="${VARIANT#-}"
base="${base:-latest}"
tag="latest${VARIANT}"
else
base="${PY}${VARIANT}"
tag="python-${PY}${VARIANT}"
fi
echo "base=$base" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@99012661954931238ded8c8b007157a8430204e1 # v4.4.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1
- name: Log in to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ${{ env.IMAGE }}
flavor: latest=false
tags: type=raw,value=${{ steps.vars.outputs.tag }}
- name: Build and push
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: PYTHON_TAG=${{ steps.vars.outputs.base }}
pull: true
# Scheduled runs skip the cache so apt and pip layers are refreshed too
no-cache: ${{ github.event_name == 'schedule' }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ steps.vars.outputs.tag }}
cache-to: type=gha,mode=max,scope=${{ steps.vars.outputs.tag }}