@@ -300,67 +300,67 @@ jobs:
300300 name : ${{ runner.os }}-biocversion-${{ matrix.config.bioc }}-r-${{ matrix.config.r }}-results
301301 path : check
302302
303- docker-build-and-push :
304- runs-on : ubuntu-latest
305- needs : build-check
306- if : " !contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
307- steps :
308- - name : Checkout Repository
309- uses : actions/checkout@v3
310-
311- - name : Extract package version from DESCRIPTION
312- id : pkg_version
313- run : |
314- PKG_VERSION=$(grep "^Version:" DESCRIPTION | awk '{print $2}')
315- echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
316- echo "Package version: $PKG_VERSION"
317-
318- - name : Set repository name as environment variable
319- run : |
320- REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')
321- echo "CONT_IMG_NAME=$REPO_NAME" >> $GITHUB_ENV
322-
323- - name : Check if container with this version already exists
324- id : check_image
325- run : |
326- # Install jq for JSON parsing
327- sudo apt-get update && sudo apt-get install -y jq
328-
329- # Query Docker Hub API
330- TAG_EXISTS=$(curl -s "https://hub.docker.com/v2/repositories/${{ secrets.DOCKERHUB_USERNAME }}/${CONT_IMG_NAME}/tags/${{ env.PKG_VERSION }}/" | jq -r '.name')
331-
332- if [ "$TAG_EXISTS" = "${{ env.PKG_VERSION }}" ]; then
333- echo "Container with version ${{ env.PKG_VERSION }} already exists. Will only push devel tag."
334- echo "PUSH_VERSION=false" >> $GITHUB_ENV
335- else
336- echo "Container with version ${{ env.PKG_VERSION }} not found. Will push both version and devel tags."
337- echo "PUSH_VERSION=true" >> $GITHUB_ENV
338- fi
339-
340- - name : Set up Docker Buildx
341- uses : docker/setup-buildx-action@v2
342-
343- - name : Login to Docker Hub
344- uses : docker/login-action@v2
345- with :
346- username : ${{ secrets.DOCKERHUB_USERNAME }}
347- password : ${{ secrets.DOCKERHUB_TOKEN }}
348-
349- - name : Build and Push Docker (version + devel tags)
350- if : env.PUSH_VERSION == 'true'
351- uses : docker/build-push-action@v4
352- with :
353- context : .
354- push : true
355- tags : |
356- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:${{ env.PKG_VERSION }}
357- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
358-
359- - name : Build and Push Docker (devel tag only)
360- if : env.PUSH_VERSION == 'false'
361- uses : docker/build-push-action@v4
362- with :
363- context : .
364- push : true
365- tags : |
366- ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
303+ docker-build-and-push :
304+ runs-on : ubuntu-latest
305+ needs : build-check
306+ if : " !contains(github.event.head_commit.message, '/nodocker') && env.run_docker == 'true' && github.ref == 'refs/heads/devel'"
307+ steps :
308+ - name : Checkout Repository
309+ uses : actions/checkout@v3
310+
311+ - name : Extract package version from DESCRIPTION
312+ id : pkg_version
313+ run : |
314+ PKG_VERSION=$(grep "^Version:" DESCRIPTION | awk '{print $2}')
315+ echo "PKG_VERSION=$PKG_VERSION" >> $GITHUB_ENV
316+ echo "Package version: $PKG_VERSION"
317+
318+ - name : Set repository name as environment variable
319+ run : |
320+ REPO_NAME=$(echo ${{ github.event.repository.name }} | tr '[:upper:]' '[:lower:]')
321+ echo "CONT_IMG_NAME=$REPO_NAME" >> $GITHUB_ENV
322+
323+ - name : Check if container with this version already exists
324+ id : check_image
325+ run : |
326+ # Install jq for JSON parsing
327+ sudo apt-get update && sudo apt-get install -y jq
328+
329+ # Query Docker Hub API
330+ TAG_EXISTS=$(curl -s "https://hub.docker.com/v2/repositories/${{ secrets.DOCKERHUB_USERNAME }}/${CONT_IMG_NAME}/tags/${{ env.PKG_VERSION }}/" | jq -r '.name')
331+
332+ if [ "$TAG_EXISTS" = "${{ env.PKG_VERSION }}" ]; then
333+ echo "Container with version ${{ env.PKG_VERSION }} already exists. Will only push devel tag."
334+ echo "PUSH_VERSION=false" >> $GITHUB_ENV
335+ else
336+ echo "Container with version ${{ env.PKG_VERSION }} not found. Will push both version and devel tags."
337+ echo "PUSH_VERSION=true" >> $GITHUB_ENV
338+ fi
339+
340+ - name : Set up Docker Buildx
341+ uses : docker/setup-buildx-action@v2
342+
343+ - name : Login to Docker Hub
344+ uses : docker/login-action@v2
345+ with :
346+ username : ${{ secrets.DOCKERHUB_USERNAME }}
347+ password : ${{ secrets.DOCKERHUB_TOKEN }}
348+
349+ - name : Build and Push Docker (version + devel tags)
350+ if : env.PUSH_VERSION == 'true'
351+ uses : docker/build-push-action@v4
352+ with :
353+ context : .
354+ push : true
355+ tags : |
356+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:${{ env.PKG_VERSION }}
357+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
358+
359+ - name : Build and Push Docker (devel tag only)
360+ if : env.PUSH_VERSION == 'false'
361+ uses : docker/build-push-action@v4
362+ with :
363+ context : .
364+ push : true
365+ tags : |
366+ ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.CONT_IMG_NAME }}:devel
0 commit comments