-
Notifications
You must be signed in to change notification settings - Fork 31
50 lines (45 loc) · 1.96 KB
/
update_latest.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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