-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
195 additions
and
190 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,157 @@ | ||
name: ~build CUDA+Python base container | ||
description: Builds the base container | ||
|
||
inputs: | ||
ARCHITECTURE: | ||
description: "CPU architecture to build the image for, e.g. amd64, arm64" | ||
required: true | ||
BASE_IMAGE: | ||
description: "Base CUDA image, e.g. nvidia/cuda:X.Y.Z-devel-ubuntu22.04" | ||
required: false | ||
default: latest | ||
BUILD_DATE: | ||
description: "Build date in YYYY-MM-DD format" | ||
required: false | ||
default: "NOT SPECIFIED" | ||
ARTIFACT_NAME: | ||
description: "Name of the artifact zip file" | ||
required: false | ||
default: "artifact-base-build" | ||
BADGE_FILENAME: | ||
description: "Name of the endpoint JSON file for shields.io badge" | ||
required: false | ||
default: "badge-base-build" | ||
GIT_USER_NAME: | ||
description: "Username in GIT to perform git pull/push" | ||
required: false | ||
default: "JAX Toolbox" | ||
GIT_USER_EMAIL: | ||
description: "User email in GIT to perform git pull/push" | ||
required: false | ||
default: "[email protected]" | ||
MANIFEST_ARTIFACT_NAME: | ||
description: Artifact name in current run w/ manifest/patches. Leaving empty uses manifest/patches in current branch | ||
default: "" | ||
required: false | ||
|
||
outputs: | ||
DOCKER_TAG: | ||
description: "Tag of the image built" | ||
value: ${{ steps.meta.outputs.tags }} | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Print environment variables | ||
shell: bash | ||
run: env | ||
|
||
- name: Check out the repository under ${GITHUB_WORKSPACE} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Delete checked-out manifest and patches | ||
if: inputs.MANIFEST_ARTIFACT_NAME != '' | ||
shell: bash | ||
run: | | ||
rm .github/container/manifest.yaml | ||
rm -rf .github/container/patches | ||
- name: Replace checked-out manifest file/patches with bumped one | ||
if: inputs.MANIFEST_ARTIFACT_NAME != '' | ||
uses: actions/download-artifact@v4 | ||
with: | ||
name: ${{ inputs.MANIFEST_ARTIFACT_NAME }} | ||
path: .github/container/ | ||
|
||
- name: Log the changes in manifest file and patch folder | ||
working-directory: .github/container | ||
shell: bash -x -e {0} | ||
run: | | ||
ls -lah | ||
ls -lah patches | ||
echo "Changes in manifest file and patch folder" | ||
git diff | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ env.GITHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
driver-opts: | | ||
image=moby/buildkit:v0.12.1 | ||
- name: Set docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ env.UPLD_IMAGE }} | ||
flavor: | | ||
latest=false | ||
tags: | | ||
type=raw,value=${{ github.run_id }}-base-${{ inputs.ARCHITECTURE }} | ||
labels: org.opencontainers.image.created=${{ inputs.BUILD_DATE }} | ||
|
||
- name: Build docker images | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: .github/container | ||
push: true | ||
file: .github/container/Dockerfile.base | ||
platforms: linux/${{ inputs.ARCHITECTURE }} | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
build-args: | | ||
GIT_USER_NAME=${{ inputs.GIT_USER_NAME }} | ||
GIT_USER_EMAIL=${{ inputs.GIT_USER_EMAIL }} | ||
BUILD_DATE=${{ inputs.BUILD_DATE }} | ||
${{ inputs.BASE_IMAGE != 'latest' && format('BASE_IMAGE={0}', inputs.BASE_IMAGE) || '' }} | ||
- name: Generate sitrep | ||
if: "!cancelled()" | ||
shell: bash -x -e {0} | ||
run: | | ||
# bring in utility functions | ||
source .github/workflows/scripts/to_json.sh | ||
badge_label='Base image ${{ inputs.ARCHITECTURE }} build' | ||
tags="${{ steps.meta.outputs.tags }}" | ||
digest="${{ steps.build.outputs.digest }}" | ||
outcome="${{ steps.build.outcome }}" | ||
if [[ ${outcome} == "success" ]]; then | ||
badge_message="pass" | ||
badge_color=brightgreen | ||
summary="Base image build on ${{ inputs.ARCHITECTURE }}: $badge_message" | ||
else | ||
badge_message="fail" | ||
badge_color=red | ||
summary="Base image build on ${{ inputs.ARCHITECTURE }}: $badge_message" | ||
fi | ||
to_json \ | ||
summary \ | ||
badge_label tags digest outcome \ | ||
> sitrep.json | ||
schemaVersion=1 \ | ||
label="${badge_label}" \ | ||
message="${badge_message}" \ | ||
color="${badge_color}" \ | ||
to_json schemaVersion label message color \ | ||
> ${{ env.BADGE_FILENAME_FULL }} | ||
- name: Upload sitrep and badge | ||
if: "!cancelled()" | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: ${{ inputs.ARTIFACT_NAME }}-${{ inputs.ARCHITECTURE }} | ||
path: | | ||
sitrep.json | ||
${{ env.BADGE_FILENAME_FULL }} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.