Added Actions workflow to publish Docker images #5
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
| --- | |
| 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] #, pypy] | |
| python_version: ["3.10", "3.11", "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" | |
| 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: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY_WITH_PATH }}/django-docker-box | |
| # yamllint disable rule:line-length | |
| tags: | | |
| type=raw,value=${{ matrix.python_implementation }}-${{ matrix.python_version }}-django-${{ matrix.django_version }} | |
| # yamllint enable rule:line-length | |
| - 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@v5 | |
| 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 | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |