Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-update "latest" tag to latest released tag for each image base #102

Merged
merged 4 commits into from
May 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .github/workflows/update_latest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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