Add target-test-base images #1
This file contains 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: Build and push Docker images with multiple Python versions | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- 'target-test-base_jammy-py/**' | ||
- '.github/workflows/build_image_target-test-base_jammy-py.yml' | ||
pull_request: | ||
paths: | ||
- 'target-test-base_jammy-py/**' | ||
- '.github/workflows/build_image_target-test-base_jammy-py.yml' | ||
workflow_dispatch: | ||
inputs: | ||
python_3_8_17: | ||
description: 'Python 3.8.17' | ||
required: false | ||
type: boolean | ||
default: true | ||
python_3_9_17: | ||
description: 'Python 3.9.17' | ||
required: false | ||
type: boolean | ||
default: false | ||
# Add more versions as needed... | ||
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"] # Add more versions as needed. | ||
include: | ||
- python_version: "3.8.17" | ||
build_this_version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.python_3_8_17 == 'true' || github.event_name != 'workflow_dispatch' }} | ||
- python_version: "3.9.17" | ||
build_this_version: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.python_3_9_x == 'true' || github.event_name != 'workflow_dispatch' }} | ||
if: ${{ matrix.build_this_version }} | ||
Check failure on line 44 in .github/workflows/build_image_target-test-base_jammy-py.yml GitHub Actions / Build and push Docker images with multiple Python versionsInvalid workflow file
|
||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v2 | ||
- 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@v1 | ||
- name: Setup Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to GitHub Container Registry (GHCR) | ||
uses: docker/login-action@v1 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and Push Docker Image (If not PR) | ||
uses: docker/build-push-action@v2 | ||
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: ${{ github.event_name != 'pull_request' }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max |