Skip to content

Build and push Docker image 'target-test-base_jammy-py' #28

Build and push Docker image 'target-test-base_jammy-py'

Build and push Docker image 'target-test-base_jammy-py' #28

# -------------------------------------------------------------------
# This GitHub Action is set up to be triggered manually.
#
# If you wish to build and push the Docker image, you must run this
# action explicitly from the GitHub Actions UI or via the GitHub API.
#
# To run this action:
# 1. Navigate to the "Actions" tab of the repository.
# 2. Find and select this workflow from the list.
# 3. Click on the "Run workflow" dropdown button.
# 4. Choose the desired parameters and confirm to start the workflow.
#
# Note: Automatic triggers (e.g., on push or pull request) have been
# disabled for this workflow. It will not run automatically upon code
# changes unless reconfigured.
# -------------------------------------------------------------------
name: Build and push Docker image 'target-test-base_jammy-py'
on:
workflow_dispatch:
inputs:
python_3_8_17:
description: 'Build Ubuntu 22.04 (Jammy) with Python 3.8.17'
required: false
type: boolean
default: true
python_3_9_17:
description: 'Build Ubuntu 22.04 (Jammy) with Python 3.9.17'
required: false
type: boolean
default: true
python_3_10_12:
description: 'Build Ubuntu 22.04 (Jammy) with Python 3.10.12'
required: false
type: boolean
default: true
python_3_11_4:
description: 'Build Ubuntu 22.04 (Jammy) with Python 3.11.4'
required: false
type: boolean
default: true
# Kill running actions pipeline (for PR) when new changes are pushed to PR
concurrency:
group: pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
env:
IMAGE_DIR: ./target-test-base_jammy-py
IMAGE_BASE_NAME: ghcr.io/${{ github.repository }}/target-test-base-jammy
IMAGE_ARCHS: linux/amd64,linux/arm
jobs:
build-and-push-docker-image:
runs-on: ubuntu-latest
strategy:
matrix:
python_version: ["3.8.17", "3.9.17", "3.10.12", "3.11.4"]
exclude:
- python_version: ${{ github.event.inputs.python_3_8_17 == 'false' && '3.8.17' || 'dummy' }}
- python_version: ${{ github.event.inputs.python_3_9_17 == 'false' && '3.9.17' || 'dummy' }}
- python_version: ${{ github.event.inputs.python_3_10_12 == 'false' && '3.10.12' || 'dummy' }}
- python_version: ${{ github.event.inputs.python_3_11_4 == 'false' && '3.11.4' || 'dummy' }}
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Extract Major/Minor Version from Full Version
id: extract_version
run: |
echo "PYTHON_VERSION=${{ matrix.python_version }}" >> $GITHUB_ENV
echo "PYTHON_VERSION_MM=$(echo "${{ matrix.python_version }}" | cut -d'.' -f1,2)" >> $GITHUB_ENV
- name: Setup QEMU for Multi-Arch Builds
uses: docker/setup-qemu-action@v2
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull Docker image to use as cache (for master)
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
run: |
docker pull ${{ env.IMAGE_BASE_NAME }}:py${{ matrix.python_version }} || true
- name: Cache Docker layers (for PRs)
if: github.event_name == 'pull_request'
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: buildx-${{ matrix.python_version }}-${{ github.sha }}
restore-keys: |
buildx-${{ matrix.python_version }}-
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
context: ${{ env.IMAGE_DIR }}
platforms: ${{env.IMAGE_ARCHS}}
tags: ${{ env.IMAGE_BASE_NAME }}:py${{ matrix.python_version }}
build-args: |
PYTHON_VERSION=${{ env.PYTHON_VERSION }}
PYTHON_VERSION_MM=${{ env.PYTHON_VERSION_MM }}
push: true
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache