Skip to content

trigger-build

trigger-build #6

Workflow file for this run

name: Build Python Image
on:
push:
branches:
- main
paths:
- "python/**"
- ".github/workflows/build_python.yml"
pull_request:
paths:
- "python/**"
- ".github/workflows/build_python.yml"
workflow_dispatch:
inputs:
no-cache:
description: "Disable cache for build"
required: false
default: false
type: boolean
repository_dispatch:
types: [trigger-build]
jobs:
build:
name: Build and Push Docker Image
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-python-${{ matrix.python_version }}
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.ref_name != github.event.repository.default_branch }}
strategy:
matrix:
python_version: ["3.9", "3.10", "3.11", "3.12"]
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up QEMU
if: github.ref_name == github.event.repository.default_branch
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx (QEMU)
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
flavor: |
suffix=-${{ matrix.python_version }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=raw,value=${{ matrix.python_version }},suffix=,enable={{is_default_branch}}
type=raw,value=latest,suffix=,enable=${{ github.ref_name == github.event.repository.default_branch && matrix.python_version == '3.12' }}
type=edge,branch=main
images: |
ghcr.io/${{ github.repository }}/python
- name: Build and push
uses: docker/build-push-action@v4
with:
context: python
pull: true
push: ${{ !(github.event_name == 'push' && github.ref_name != github.event.repository.default_branch) }}
platforms: ${{ (github.ref_type == 'tag' || github.ref_name == github.event.repository.default_branch) && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
no-cache: ${{ inputs.no-cache || false }}
cache-from: type=gha
cache-to: type=gha,mode=max,ignore-error=true
build-args: |
PYTHON_VERSION=${{ matrix.python_version }}