Skip to content

Commit

Permalink
differentiate between image name and image dir
Browse files Browse the repository at this point in the history
  • Loading branch information
daler committed Jan 28, 2024
1 parent 4eeb784 commit 1463464
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions .github/workflows/bioconda-utils-build-env-cos7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ jobs:
# version tags or checksum IDs, but not via "latest".
MAJOR_VERSION: 3
MINOR_VERSION: 1

# Used for testing -- set to something like 'tmp-' or 'test-' to prefix
# images with this name during testing
IMAGE_PREFIX: "tmp-"
IMAGE_NAME: bioconda-utils-build-env-cos7

steps:
Expand All @@ -44,20 +48,23 @@ jobs:
id: build
run: |
set -xeu
cd 'images/${{ env.IMAGE_NAME }}'
image_name='${{ env.IMAGE_NAME }}'
image_name='${{ env.IMAGE_PREFIX }}${{ env.IMAGE_NAME }}'
image_dir='images/${{ env.IMAGE_NAME }}'
tags='
${{ env.MAJOR_VERSION }}
${{ env.MAJOR_VERSION }}.${{ env.MINOR_VERSION }}
latest
'
# Adds image and tags to outputs which can be used in later steps.
printf %s\\n \
"image=${image_name}" \
"image_dir=${image_dir}" \
"image_name=${image_name}" \
"tags=$( echo ${tags} )" \
>> $GITHUB_OUTPUT
cd 'images/${{ env.IMAGE_NAME }}'
# Create manifest (which is considered arch-independent)
for tag in ${tags} ; do
buildah manifest create "${image_name}:${tag}"
Expand Down Expand Up @@ -120,7 +127,8 @@ jobs:
- name: Test
run: |
image='${{ steps.build.outputs.image }}'
image_name='${{ steps.build.outputs.image_name }}'
image_dir='${{ steps.build.outputs.image_dir }}'
# Extract image ids from manifest to test.
ids="$(
Expand All @@ -141,7 +149,7 @@ jobs:
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
"images/${image}"
"${image_dir}"
done
buildah rmi --prune || true
Expand All @@ -151,7 +159,7 @@ jobs:
# => Try to use the REST API to check for duplicate tags and exit if they exist
response="$(
curl -sL \
'https://quay.io/api/v1/repository/bioconda/${{ steps.build.outputs.image }}/tag/'
'https://quay.io/api/v1/repository/bioconda/${{ steps.build.outputs.image_name }}/tag/'
)"
existing_tags="$(
Expand Down Expand Up @@ -181,7 +189,7 @@ jobs:
name: Push
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build.outputs.image }}
image: ${{ steps.build.outputs.image_name }}
tags: ${{ steps.build.outputs.tags }}
registry: ${{ secrets.QUAY_BIOCONDA_REPO }}
username: ${{ secrets.QUAY_BIOCONDA_USERNAME }}
Expand All @@ -190,10 +198,12 @@ jobs:
- if: ${{ github.ref == 'refs/heads/test-push' }}
name: Test Pushed
run: |
image='${{ env.IMAGE_NAME }}'
image_name='${{ steps.build.outputs.image_name }}'
image_dir='${{ steps.build.outputs.image_dir }}'
ids="$(
for tag in ${{ steps.build.outputs.tags }} ; do
buildah manifest inspect "${image}:${tag}" \
buildah manifest inspect "${image_name}:${tag}" \
| jq -r '.manifests[]|.digest' \
| while read id ; do
buildah images --format '{{.ID}}{{.Digest}}' \
Expand All @@ -207,6 +217,6 @@ jobs:
buildah bud \
--build-arg=base="${id}" \
--file=Dockerfile.test \
"images/${image}"
"${image_dir}"
done
buildah rmi --prune || true

0 comments on commit 1463464

Please sign in to comment.