Skip to content

Commit

Permalink
Merge pull request #34 from opensafely-core/fix-publish
Browse files Browse the repository at this point in the history
Fix and improve publishing workflow
  • Loading branch information
bloodearnest authored Oct 23, 2024
2 parents 9d63f98 + b5a98ab commit 5b4e9d1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 26 deletions.
29 changes: 3 additions & 26 deletions .github/workflows/build_and_publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,14 @@ 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
run: just lint
- 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
21 changes: 21 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 5b4e9d1

Please sign in to comment.