-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only rebuild images on request, or once 14 days old
- Loading branch information
1 parent
848e50e
commit 92be952
Showing
2 changed files
with
106 additions
and
37 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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
name: Build Fenix's Environment Image | ||
|
||
on: | ||
# workflow_call = called by another workflow | ||
workflow_call: | ||
inputs: | ||
ompi_version: | ||
description: "Open MPI version to build" | ||
type: string | ||
required: true | ||
max_age: | ||
description: "Maximum image age before rebuild, in days" | ||
type: number | ||
required: false | ||
default: 14 | ||
# workflow_dispatch = manual trigger | ||
workflow_dispatch: | ||
inputs: | ||
ompi_version: | ||
description: "Open MPI version to build" | ||
type: string | ||
required: true | ||
max_age: | ||
description: "Maximum image age before rebuild, in days" | ||
type: number | ||
required: false | ||
default: 0 | ||
|
||
env: | ||
IMAGE_NAME: ghcr.io/sandialabs/fenix/env | ||
IMAGE_TAG: ${{ github.event.inputs.ompi_version }} | ||
|
||
jobs: | ||
detect_image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check for valid image | ||
run: | | ||
IMG=${IMAGE_NAME}:${{ inputs.ompi_version }} | ||
docker image rm -f $IMG; docker pull $IMG || true | ||
IMG_CREATED=$(docker inspect --type=image --format '{{.Created}}' $IMG 2>/dev/null) | ||
if [ -z "$IMG_CREATED" ]; then | ||
echo "found=false" >> $GITHUB_OUTPUT | ||
exit 0 | ||
fi | ||
IMG_AGE=$(( ($(date +%s) - $(date -d "$IMG_CREATED" +%s)) / (60*60*24) )) | ||
if [ "$IMG_AGE" -lt ${{ github.event.inputs.max_age }} ]; then | ||
echo "found=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "found=false" >> $GITHUB_OUTPUT | ||
fi | ||
outputs: | ||
found: ${{ job.steps.outputs.found }} | ||
|
||
build_image: | ||
runs-on: ubuntu-latest | ||
needs: detect_image | ||
if: needs.detect_image.outputs.found == 'false' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Log in to GHCR container registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Bake the bootstrap docker image | ||
uses: docker/bake-action@v5 | ||
with: | ||
files: .github/docker-compose.yml | ||
targets: bootstrap | ||
workdir: . | ||
set: | | ||
*.output=type=docker,name=bootstrap | ||
*.cache-from=type=gha,scope=bootstrap/${{ github.event.inputs.ompi_version }} | ||
*.cache-to=type=gha,mode=max,scope=bootstrap/${{ github.event.inputs.ompi_version }} | ||
*.args.OMPI_VERSION=${{ github.event.inputs.ompi_version }} | ||
- name: Bootstrap the environment Dockerfile | ||
run: docker run -v ${GITHUB_WORKSPACE}/.github:/configs bootstrap | ||
|
||
- name: Build the environment | ||
uses: docker/bake-action@v5 | ||
with: | ||
files: .github/docker-compose.yml | ||
targets: env | ||
workdir: . | ||
pull: true | ||
set: | | ||
*.cache-from=type=gha,scope=env/${{ github.event.inputs.ompi_version }} | ||
*.cache-to=type=gha,mode=max,scope=env/${{ github.event.inputs.ompi_version }} | ||
env.tags=ghcr.io/sandialabs/fenix/env:${{ github.event.inputs.ompi_version }} | ||
env.output=type=registry,name=ghcr.io/sandialabs/fenix/env:${{ github.event.inputs.ompi_version }} |
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