Skip to content

Make base images multiarch #58

Make base images multiarch

Make base images multiarch #58

Workflow file for this run

name: 'Build & Push: create-env'
on:
push:
branches:
- main
paths:
- images/create-env/*
- .github/workflows/create-env.yaml
pull_request:
paths:
- images/create-env/*
- .github/workflows/create-env.yaml
jobs:
build:
name: Build & Push
runs-on: ubuntu-20.04
env:
IMAGE_VERSION: '3.0.0'
IMAGE_NAME: create-env
steps:
- uses: actions/checkout@v3
- name: Prepare
id: prepare
run: |
curl -sSL \
'https://raw.githubusercontent.com/bioconda/bioconda-common/master/common.sh' \
| sed -n \
's/BIOCONDA_UTILS_TAG=v/::set-output name=bioconda_utils_version::/p'
- name: Build
id: buildah-build
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.IMAGE_NAME }}
tags: >-
latest
${{ env.IMAGE_VERSION }}
archs: amd64
context: ./images/${{ env.IMAGE_NAME }}
containerfiles: |
./images/${{ env.IMAGE_NAME }}/Dockerfile
build-args: |
bioconda_utils_version=${{ steps.prepare.outputs.bioconda_utils_version }}
- name: Test
run: |
image='${{ steps.buildah-build.outputs.image }}'
ids="$(
for tag in ${{ steps.buildah-build.outputs.tags }} ; do
buildah images --quiet --no-trunc "${image}:${tag}"
done
)"
ids="$( printf %s "${ids}" | sort -u )"
for id in ${ids} ; do
podman history "${id}"
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
"images/${image}"
done
buildah rmi --prune || true
- name: Check Tags
run: |
# FIX upstream: Quay.io does not support immutable images currently.
# => Try to use the REST API to check for duplicate tags.
page=0
has_additional='true'
while [ "${has_additional}" = 'true' ] ; do
page="$(( page + 1 ))"
respone="$(
curl -sL -H "Authorization: Bearer ${{ secrets.QUAY_BIOCONDA_TOKEN }}" \
'https://quay.io/api/v1/repository/bioconda/${{ steps.buildah-build.outputs.image }}/tag?limit=100&page='"${page}"
)"
has_additional="$( printf %s "${respone}" | jq -r '.has_additional' )"
existing_tags="$(
printf %s "${respone}" \
| jq -r '.tags[]|.name'
)" \
|| {
>&2 printf %s\\n \
'Could not get list of image tags.' \
'Does the repository exist on Quay.io?' \
'Quay.io REST API response was:' \
"${respone}"
exit 1
}
for tag in ${{ steps.buildah-build.outputs.tags }} ; do
if [ \! "${tag}" = latest ] ; then
if printf %s "${existing_tags}" | grep -qxF "${tag}" ; then
>&2 printf 'Tag %s already exists!\n' "${tag}"
exit 1
fi
fi
done
done
- if: ${{ github.ref == 'refs/heads/main' }}
name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.buildah-build.outputs.image }}
tags: ${{ steps.buildah-build.outputs.tags }}
registry: ${{ secrets.QUAY_BIOCONDA_REPO }}
username: ${{ secrets.QUAY_BIOCONDA_USERNAME }}
password: ${{ secrets.QUAY_BIOCONDA_TOKEN }}
- if: ${{ github.ref == 'refs/heads/main' }}
name: Test Pushed
run: |
image='${{ steps.buildah-build.outputs.image }}'
ids="$(
for tag in ${{ steps.buildah-build.outputs.tags }} ; do
buildah images --quiet --no-trunc "${image}:${tag}"
done
)"
ids="$( printf %s "${ids}" | sort -u )"
for id in ${ids} ; do
podman history "${id}"
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
"images/${image}"
done
buildah rmi --prune || true