diff --git a/.github/workflows/base-glibc-busybox-bash.yaml b/.github/workflows/base-glibc-busybox-bash.yaml index 300702a8..9629acd3 100644 --- a/.github/workflows/base-glibc-busybox-bash.yaml +++ b/.github/workflows/base-glibc-busybox-bash.yaml @@ -20,9 +20,12 @@ jobs: # version tags or checksum IDs, but not via "latest". MAJOR_VERSION: 3 MINOR_VERSION: 1 - IMAGE_NAME: base-glibc-busybox-bash BUSYBOX_VERSION: '1.36.1' DEBIAN_VERSION: '12.2' + # Used for testing -- set to something like 'tmp-' or 'test-' to prefix + # images with this name during testing + IMAGE_PREFIX: "tmp-" + IMAGE_NAME: base-glibc-busybox-bash steps: - uses: actions/checkout@v4 @@ -36,9 +39,9 @@ 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 }} @@ -46,10 +49,13 @@ jobs: ' # 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}" @@ -112,7 +118,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="$( @@ -133,7 +140,7 @@ jobs: buildah bud \ --build-arg=base="${id}" \ --file=Dockerfile.test \ - "images/${image}" + "${image_dir}" done buildah rmi --prune || true @@ -143,9 +150,16 @@ 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/' )" + # This might be the first time making this image (e.g., will likely + # happen when using a test prefix), in which case there will be no + # available images. + if [ "$(echo "${response}" | jq -r '.error_message')" == "Requires authentication" ]; then + exit 0 + fi + existing_tags="$( printf %s "${response}" \ | jq -r '.tags[]|select(.end_ts == null or .end_ts >= now)|.name' @@ -169,23 +183,25 @@ jobs: esac done - - if: ${{ github.ref == 'refs/heads/main' }} + - if: ${{ github.ref == 'refs/heads/test-push' }} 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 }} + registry: quay.io/bioconda username: ${{ secrets.QUAY_BIOCONDA_USERNAME }} password: ${{ secrets.QUAY_BIOCONDA_TOKEN }} - - if: ${{ github.ref == 'refs/heads/main' }} + - 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}}' \ @@ -199,6 +215,6 @@ jobs: buildah bud \ --build-arg=base="${id}" \ --file=Dockerfile.test \ - "images/${image}" + "${image_dir}" done buildah rmi --prune || true