WIP: More experiments with metadata: ref needs event #30
Workflow file for this run
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: Publish Docker images | |
on: [push] | |
env: | |
REGISTRY: quay.io | |
ORGANIZATION: casacore | |
IMAGE: ${{ github.repository }} | |
jobs: | |
build_images: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ['3.7'] #, '3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to registry | |
uses: docker/login-action@v3 | |
with: | |
# Credentials for robot account "github" on Quay for organization "casacore" | |
registry: ${{ env.REGISTRY }} | |
username: ${{ secrets.QUAY_USERNAME }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Determine build-args | |
id: args | |
run: | | |
echo "Checking out GitHub repository: ${{ env.IMAGE }}" | |
echo "Python version: ${{ matrix.python-version }}" | |
py_major=$(echo ${{ matrix.python-version }} | cut -d'.' -f1) | |
py_minor=$(echo ${{ matrix.python-version }} | cut -d'.' -f2) | |
# if [ ${py_major} -eq 3 ] && [ ${py_minor} -le 7 ]; then py_unicode="m"; else py_unicode=; fi | |
[ ${py_major} -eq 3 ] && [ ${py_minor} -le 7 ] && py_unicode="m" || py_unicode= | |
echo "py_major=${py_major}; py_minor=${py_minor}; py_unicode=${py_unicode}" | |
# which git | |
# git_tag=$(git describe --tags --dirty) ## TODO: Probably git is not avaiable ?! | |
echo "PYMAJOR=${py_major}" >> "$GITHUB_OUTPUT" | |
echo "PYMINOR=${py_minor}" >> "$GITHUB_OUTPUT" | |
echo "PYUNICODE=${py_unicode}" >> "$GITHUB_OUTPUT" | |
# echo "REPOSITORY=${{ env.REGISTRY }}/${{ env.ORGANIZATION}}/${{ env.IMAGE }}" >> "$GITHUB_OUTPUT" | |
# echo "TAG=$(git describe --tags)_py${py_major}${py_minor}" >> "$GITHUB_OUTPUT" | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
flavor: | |
prefix=py${{ steps.args.outputs.PYMAJOR }}${{ steps.args.outputs.PYMINOR }} | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE }} | |
tags: | | |
type=schedule | |
type=semver,pattern={{major}}.{{minor}} | |
type=pep440,pattern={{version}} | |
# type=match | |
type=edge | |
type=ref,event=branch | |
type=ref,event=tag | |
type=ref,event=pr | |
type=raw | |
type=sha | |
# type=schedule | |
# type=ref,event=branch | |
# type=ref,event=pr | |
# type=semver,pattern={{version}} | |
# type=semver,pattern={{major}}.{{minor}} | |
# type=semver,pattern={{major}} | |
# type=sha | |
# - name: Build docker image | |
# run: | | |
# git_tag=$(git describe --tags --dirty) | |
# py_major=$(echo ${{ matrix.python-version }} | cut -d'.' -f1) | |
# py_minor=$(echo ${{ matrix.python-version }} | cut -d'.' -f2) | |
# [ ${py_major} -eq 3 ] && [ ${py_minor} -le 7 ] && py_unicode="m" || py_unicode= | |
# echo docker build \ | |
# --build-arg PYMAJOR=${py_major} \ | |
# --build-arg PYMINOR=${py_minor} \ | |
# --build-arg PYUNICODE=${py_unicode} \ | |
# --file ./docker/py_wheel.docker \ | |
# --tag ${{ env.REGISTRY }}/${{ env.ORGANIZATION}}/${{ env.IMAGE }} | |
- name: Build and push docker image | |
uses: docker/build-push-action@v5 | |
with: | |
build-args: | | |
PYMAJOR=${{ steps.args.outputs.PYMAJOR }} | |
PYMINOR=${{ steps.args.outputs.PYMINOR }} | |
PYUNICODE=${{ steps.args.outputs.PYUNICODE }} | |
# PYMAJOR=${PYMAJOR} | |
# PYMINOR=${PYMINOR} | |
# PYUNICODE=${PYUNICODE} | |
# context: . | |
file: docker/py_wheel.docker | |
push: false | |
# tags: "${{ steps.args.outputs.REPOSITORY }}:${{ steps.args.outputs.TAG }}" | |
# labels: ${{ steps.meta.outputs.labels }} | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |