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

Fix and improve publishing workflow #34

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
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
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
Loading