forked from orf/django-docker-box
-
Notifications
You must be signed in to change notification settings - Fork 42
Published Docker images to GitHub Packages #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
tobiasmcnulty
wants to merge
6
commits into
main
Choose a base branch
from
pkgs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+153
−5
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dee5c44
Added Actions workflow to publish Docker images
tobiasmcnulty 55d99b1
Ran tests in published images
tobiasmcnulty 8b33902
Revert "Removed DEFAULT_AUTO_FIELD setting."
tobiasmcnulty 63094e5
Only set DEFAULT_AUTO_FIELD for Django <= 5.2
tobiasmcnulty 0ba71c1
Disabled colors in terminal output
tobiasmcnulty e112a69
Upgraded `MARIADB_VERSION=10.11`
tobiasmcnulty File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
--- | ||
name: Publish Docker images for Django Docker Box | ||
|
||
on: # yamllint disable-line rule:truthy | ||
push: | ||
branches: [pkgs] | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
REGISTRY_WITH_PATH: ghcr.io/${{ github.repository_owner }} | ||
|
||
jobs: | ||
build-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
strategy: | ||
matrix: | ||
python_implementation: [python] | ||
python_version: ["3.12", "3.13"] | ||
django_version: ["4.2", "5.1", "5.2", "main"] | ||
exclude: | ||
# Exclude PyPy versions that are not available | ||
- python_implementation: pypy | ||
python_version: "3.12" | ||
- python_implementation: pypy | ||
python_version: "3.13" | ||
env: | ||
# yamllint disable rule:line-length | ||
DOCKER_IMAGE_TAG: ${{ matrix.python_implementation }}-${{ matrix.python_version }}-django-${{ matrix.django_version }} | ||
# yamllint enable rule:line-length | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY_WITH_PATH }}/django-docker-box | ||
tags: | | ||
type=raw,value=${{ env.DOCKER_IMAGE_TAG }} | ||
- name: Download Django source | ||
# yamllint disable rule:line-length | ||
run: | | ||
if [ "${{ matrix.django_version }}" = "main" ]; then | ||
branch=main | ||
dirname=django-main | ||
else | ||
branch=stable/${{ matrix.django_version }}.x | ||
dirname=django-stable-${{ matrix.django_version }}.x | ||
fi | ||
curl -L https://github.com/django/django/archive/refs/heads/$branch.tar.gz | tar xz | ||
mv $dirname django-src | ||
# yamllint enable rule:line-length | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v6 | ||
with: | ||
context: . | ||
file: Containerfile | ||
push: ${{ github.event_name != 'pull_request' }} | ||
build-args: | | ||
PYTHON_IMPLEMENTATION=${{ matrix.python_implementation }} | ||
PYTHON_VERSION=${{ matrix.python_version }} | ||
DJANGO_PATH=django-src | ||
build-contexts: | | ||
src=django-src | ||
# yamllint disable rule:line-length | ||
cache-from: type=registry,ref=${{ env.REGISTRY_WITH_PATH }}/django-docker-box:buildcache-${{ env.DOCKER_IMAGE_TAG }} | ||
cache-to: type=registry,ref=${{ env.REGISTRY_WITH_PATH }}/django-docker-box:buildcache-${{ env.DOCKER_IMAGE_TAG }},mode=max | ||
# yamllint enable rule:line-length | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
test-image: | ||
needs: build-push-image | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python_implementation: [python] | ||
python_version: ["3.12", "3.13"] | ||
django_version: ["5.2", "main"] | ||
test_service: | ||
- mariadb | ||
- mysql | ||
- oracle | ||
- postgresql | ||
- sqlite | ||
- mariadb-gis | ||
- mysql-gis | ||
- oracle-gis | ||
- postgresql-gis | ||
- sqlite-gis | ||
fail-fast: false | ||
env: | ||
REGISTRY: ghcr.io | ||
REGISTRY_PATH: ghcr.io/${{ github.repository_owner }}/django-docker-box | ||
# yamllint disable rule:line-length | ||
IMAGE_TAG: ${{ matrix.python_implementation }}-${{ matrix.python_version }}-django-${{ matrix.django_version }} | ||
# yamllint enable rule:line-length | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.workflow_run.head_sha }} | ||
- name: Log into registry ${{ env.REGISTRY }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Pull image | ||
run: | | ||
docker pull ${{ env.REGISTRY_PATH }}:${{ env.IMAGE_TAG }} | ||
# yamllint disable rule:line-length | ||
- name: Download Django source | ||
run: | | ||
if [ "${{ matrix.django_version }}" = "main" ]; then | ||
branch=main | ||
dirname=django-main | ||
else | ||
branch=stable/${{ matrix.django_version }}.x | ||
dirname=django-stable-${{ matrix.django_version }}.x | ||
fi | ||
curl -L https://github.com/django/django/archive/refs/heads/$branch.tar.gz | tar xz | ||
mv $dirname django-src | ||
# yamllint enable rule:line-length | ||
- name: Run tests for ${{ matrix.test_service }} | ||
run: | | ||
export DOCKER_BOX_IMAGE=${{ env.REGISTRY_PATH }}:${{ env.IMAGE_TAG }} | ||
export DJANGO_PATH=./django-src/ | ||
docker compose run --rm ${{ matrix.test_service }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminal colors break some tests that look for terminal output on Python 3.13.