-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for existing base image to speedup pipelines.
- Loading branch information
1 parent
7767511
commit 5f0ec6f
Showing
1 changed file
with
23 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,8 +32,29 @@ jobs: | |
# Also need to change build script to use spack from base image | ||
submodules: true | ||
|
||
# No GHCR base image with skopeo, so this will do... | ||
- name: "Set up skopeo" | ||
uses: warjiang/[email protected] | ||
with: | ||
version: latest | ||
|
||
# Use skopeo to check for image for convenience | ||
- name: Check for existing base images | ||
run: | | ||
set -e | ||
CONTAINER_TAG=${{ env.BASE_VERSION }} | ||
OCI_URL="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BASE_VERSION }}" | ||
echo Checking for CONTAINER_TAG $CONTAINER_TAG | ||
skopeo inspect \ | ||
docker://$OCI_URL \ | ||
--raw \ | ||
--creds "${{ env.USERNAME }}:${{ secrets.GITHUB_TOKEN }}" \ | ||
> /dev/null && echo "Image already exists. Please bump version." && exit 0 | ||
echo "IMAGE_EXISTS=false" >> $GITHUB_ENV | ||
# Need to build custom base image with gfortran | ||
- name: Create Dockerfile heredoc | ||
if: ${{ env.IMAGE_EXISTS == 'false' }} | ||
run: | | ||
cat << EOF > Dockerfile | ||
FROM ubuntu:24.04 | ||
|
@@ -61,13 +82,15 @@ jobs: | |
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Extract metadata (tags, labels) for Docker | ||
if: ${{ env.IMAGE_EXISTS == 'false' }} | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
labels: org.opencontainers.image.version=${{ env.BASE_VERSION }} | ||
|
||
- name: Build and push Docker base image | ||
if: ${{ env.IMAGE_EXISTS == 'false' }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
|