Skip to content

Update latest tag to latest release #212

Update latest tag to latest release

Update latest tag to latest release #212

name: Update latest tag to latest release
on:
workflow_dispatch:
schedule:
- cron: '0 18 * * *'
jobs:
update_latest:
name: "Update latest tag"
strategy:
fail-fast: false
matrix:
image: ['r-ver', 'bioconductor', 'bioconductor_docker', 'tidyverse', 'ml-verse', 'shiny']
runs-on: ubuntu-latest
steps:
- name: Set defaults for schedule
id: defs
run: |
OWNER_REPO="bioconductor"
echo repo="$OWNER_REPO" >> $GITHUB_OUTPUT
echo releasetag=$(curl https://hub.docker.com/v2/repositories/$OWNER_REPO/${{matrix.image}}/tags?page_size=1000 | jq '.results[].name' | tr -d '"' | grep -v "-" | sort -n | grep RELEASE | tail -n 1) >> $GITHUB_OUTPUT
- name: Login to GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Dockerhub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Update latest tag
run: |
OWNER_REPO="${{steps.defs.outputs.repo}}"
docker pull $OWNER_REPO/${{matrix.image}}:${{steps.defs.outputs.releasetag}}
docker pull $OWNER_REPO/${{matrix.image}}:latest
IMAGEDIFF=$(diff <(docker inspect $OWNER_REPO/${{matrix.image}}:latest) <(docker inspect $OWNER_REPO/${{matrix.image}}:${{steps.defs.outputs.releasetag}}))
if [ -z "$IMAGEDIFF" ]; then
echo '"latest" tag is already "${{steps.defs.outputs.releasetag}}"'
else
docker tag $OWNER_REPO/${{matrix.image}}:${{steps.defs.outputs.releasetag}} $OWNER_REPO/${{matrix.image}}:latest
docker push $OWNER_REPO/${{matrix.image}}:latest
docker tag $OWNER_REPO/${{matrix.image}}:${{steps.defs.outputs.releasetag}} ghcr.io/$OWNER_REPO/${{matrix.image}}:latest
docker push ghcr.io/$OWNER_REPO/${{matrix.image}}:latest
fi