From b5a98ab01b13cba683dc8394533e7b8f72499d1a Mon Sep 17 00:00:00 2001 From: bloodearnest Date: Wed, 23 Oct 2024 12:40:44 +0100 Subject: [PATCH] Fix and improve publishing workflow We still used make build, so fix that, and also move the publishing logic out of GHA and into justfile --- .github/workflows/build_and_publish.yaml | 29 +++--------------------- Justfile | 21 +++++++++++++++++ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build_and_publish.yaml b/.github/workflows/build_and_publish.yaml index 6ec72dc..0767e23 100644 --- a/.github/workflows/build_and_publish.yaml +++ b/.github/workflows/build_and_publish.yaml @@ -16,9 +16,9 @@ jobs: steps: - name: Checkout uses: actions/checkout@master - - name: Build image - run: make build - uses: extractions/setup-just@69d82fb0233557aec017ef13706851d0694e0f1d + - name: Build image + run: just build - name: Run tests run: just test - name: Run lint @@ -26,27 +26,4 @@ jobs: - name: Log into GitHub Container Registry run: echo ${{ secrets.GITHUB_TOKEN }} | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin - name: Push image to GitHub Container Registry - run: | - BASE_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$BASE_IMAGE_NAME - ACTION_IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$ACTION_IMAGE_NAME - # tag the local images with the published names - docker tag $BASE_IMAGE_NAME:20.04 $BASE_IMAGE_ID:20.04 - docker tag $BASE_IMAGE_NAME:22.04 $BASE_IMAGE_ID:22.04 - docker tag $BASE_IMAGE_NAME:24.04 $BASE_IMAGE_ID:24.04 - docker tag $ACTION_IMAGE_NAME:20.04 $ACTION_IMAGE_ID:20.04 - docker tag $ACTION_IMAGE_NAME:22.04 $ACTION_IMAGE_ID:22.04 - docker tag $ACTION_IMAGE_NAME:24.04 $ACTION_IMAGE_ID:24.04 - - # push each label up - docker push $BASE_IMAGE_ID:20.04 - docker push $BASE_IMAGE_ID:22.04 - docker push $BASE_IMAGE_ID:24.04 - docker push $ACTION_IMAGE_ID:20.04 - docker push $ACTION_IMAGE_ID:22.04 - docker push $ACTION_IMAGE_ID:24.04 - - # latest tags are 20.04 for b/w compat - docker tag $BASE_IMAGE_NAME:20.04 $BASE_IMAGE_ID:latest - docker tag $ACTION_IMAGE_NAME:20.04 $ACTION_IMAGE_ID:latest - docker push $BASE_IMAGE_ID:latest - docker push $ACTION_IMAGE_ID:latest + run: just publish-images diff --git a/Justfile b/Justfile index 824426a..60256d8 100644 --- a/Justfile +++ b/Justfile @@ -43,3 +43,24 @@ _update-sha os: echo {{ os }} docker image pull {{ os }} docker inspect --format='{{{{index .RepoDigests 0}}' {{ os }} > {{ os }}.sha + + +publish-images: + #!/bin/bash + set -euo pipefail + for version in 20.04 22.04 24.04 + do + for image_name in base-docker base-action + do + image="$image_name:$version" + full="ghcr.io/openasfely-core/$image" + docker tag $image $full + docker push $full + done + done + + # latest tags are 20.04 for b/w compat + docker tag base-docker:20.04 ghcr.io/opensafely-core/base-docker:latest + docker tag base-action:20.04 ghcr.io/opensafely-core/base-action:latest + docker push ghcr.io/opensafely-core/base-docker:latest + docker push ghcr.io/opensafely-core/base-action:latest