Skip to content

Commit 1390a97

Browse files
committed
Added Actions workflow to publish Docker images
1 parent 162ffe9 commit 1390a97

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
name: Publish Docker images for Django Docker Box
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches: [pkgs]
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
REGISTRY_WITH_PATH: ghcr.io/${{ github.repository_owner }}
11+
12+
jobs:
13+
build-push-image:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
strategy:
19+
matrix:
20+
python_implementation: [python] #, pypy]
21+
python_version: ["3.10", "3.11", "3.12", "3.13"]
22+
django_version: ["4.2", "5.1", "5.2", "main"]
23+
exclude:
24+
# Exclude PyPy versions that are not available
25+
- python_implementation: pypy
26+
python_version: "3.12"
27+
- python_implementation: pypy
28+
python_version: "3.13"
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
- name: Log into registry ${{ env.REGISTRY }}
33+
if: github.event_name != 'pull_request'
34+
uses: docker/login-action@v3
35+
with:
36+
registry: ${{ env.REGISTRY }}
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Extract Docker metadata
40+
id: meta
41+
uses: docker/metadata-action@v5
42+
with:
43+
images: ${{ env.REGISTRY_WITH_PATH }}/django-docker-box
44+
# yamllint disable rule:line-length
45+
tags: |
46+
type=raw,value=${{ matrix.python_implementation }}-${{ matrix.python_version }}-django-${{ matrix.django_version }}
47+
# yamllint enable rule:line-length
48+
- name: Download Django source
49+
# yamllint disable rule:line-length
50+
run: |
51+
if [ "${{ matrix.django_version }}" = "main" ]; then
52+
branch=main
53+
dirname=django-main
54+
else
55+
branch=stable/${{ matrix.django_version }}.x
56+
dirname=django-stable-${{ matrix.django_version }}.x
57+
fi
58+
curl -L https://github.com/django/django/archive/refs/heads/$branch.tar.gz | tar xz
59+
mv $dirname django-src
60+
# yamllint enable rule:line-length
61+
- name: Build and push Docker image
62+
uses: docker/build-push-action@v5
63+
with:
64+
context: .
65+
file: Containerfile
66+
push: ${{ github.event_name != 'pull_request' }}
67+
build-args: |
68+
PYTHON_IMPLEMENTATION=${{ matrix.python_implementation }}
69+
PYTHON_VERSION=${{ matrix.python_version }}
70+
DJANGO_PATH=django-src
71+
build-contexts: |
72+
src=django-src
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)