L2R build (push) #9
Workflow file for this run
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
name: Language to Reward 2023 build | |
run-name: L2R build (${{ github.event_name == 'workflow_run' && format('nightly {0}', github.event.workflow_run.created_at) || github.event_name }}) | |
on: | |
push: | |
workflow_run: | |
workflows: [Nightly MJX build] | |
types: [completed] | |
branches: [main] | |
workflow_dispatch: | |
inputs: | |
BASE_IMAGE_AMD64: | |
type: string | |
description: 'MJX mealkit AMD64 image built by NVIDIA/JAX-Toolbox' | |
default: '' | |
required: false | |
BASE_IMAGE_ARM64: | |
type: string | |
description: 'MJX mealkit AMD64 image built by NVIDIA/JAX-Toolbox' | |
default: '' | |
required: false | |
PUBLISH: | |
type: boolean | |
description: Publish dated images and update the 'latest' tag? | |
default: false | |
required: false | |
env: | |
DOCKER_REGISTRY: ghcr.io/nvidia | |
DEFAULT_BASE_IMAGE: ghcr.io/nvidia/jax-toolbox-internal:7664258949-upstream-mjx | |
permissions: | |
contents: read # to fetch code | |
actions: write # to cancel previous workflows | |
packages: write # to upload container | |
jobs: | |
metadata: | |
runs-on: ubuntu-22.04 | |
outputs: | |
PUBLISH: ${{ steps.if-publish.outputs.PUBLISH }} | |
BASE_IMAGE_AMD64: ${{ steps.base-image.outputs.BASE_IMAGE_AMD64 }} | |
BASE_IMAGE_ARM64: ${{ steps.base-image.outputs.BASE_IMAGE_ARM64 }} | |
BUILD_DATE: ${{ steps.date.outputs.BUILD_DATE }} | |
steps: | |
- name: Cancel workflow if upstream workflow did not success | |
if: ${{ steps.if-upstream-failed.outputs.UPSTREAM_FAILED == 'true' }} | |
run: | | |
echo "Upstream workflow failed, cancelling this workflow" | |
curl -X POST -H "Authorization: token ${{ github.token }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/cancel" | |
cat # blocks execution in case workflow cancellation takes time | |
- name: Determine if the resulting container should be 'published' | |
id: if-publish | |
shell: bash -x -e {0} | |
run: | |
# A container should be published if: | |
# 1) the workflow is triggered by workflow_dispatch and the PUBLISH input is true, or | |
# 2) the workflow is triggered by workflow_run (i.e., a nightly build) | |
echo "PUBLISH=${{ github.event_name == 'workflow_run' || (github.event_name == 'workflow_dispatch' && inputs.PUBLISH) }}" >> $GITHUB_OUTPUT | |
- name: Set build date | |
id: date | |
shell: bash -x -e {0} | |
run: | | |
BUILD_DATE=$(TZ='US/Los_Angeles' date '+%Y-%m-%d') | |
echo "BUILD_DATE=${BUILD_DATE}" >> $GITHUB_OUTPUT | |
- name: Set base image | |
id: base-image | |
shell: bash -x -e {0} | |
run: | | |
if [[ -z "${{ inputs.BASE_IMAGE }}" ]]; then | |
BASE_IMAGE_AMD64=${{ env.DEFAULT_BASE_IMAGE }}-amd64-mealkit | |
BASE_IMAGE_ARM64=${{ env.DEFAULT_BASE_IMAGE }}-arm64-mealkit | |
else | |
BASE_IMAGE_AMD64=${{ inputs.BASE_IMAGE_AMD64 }} | |
BASE_IMAGE_ARM64=${{ inputs.BASE_IMAGE_ARM64 }} | |
fi | |
echo "BASE_IMAGE_AMD64=${BASE_IMAGE_AMD64}" >> $GITHUB_OUTPUT | |
echo "BASE_IMAGE_ARM64=${BASE_IMAGE_ARM64}" >> $GITHUB_OUTPUT | |
amd64: | |
needs: metadata | |
uses: ./.github/workflows/_build.yaml | |
with: | |
ARCHITECTURE: amd64 | |
ARTIFACT_NAME: artifact-l2r-build | |
BADGE_FILENAME: badge-l2r-build | |
BASE_IMAGE: ${{ needs.metadata.outputs.BASE_IMAGE_AMD64 }} | |
BUILD_DATE: ${{ needs.metadata.outputs.BUILD_DATE }} | |
CONTAINER_NAME: l2r | |
DOCKERFILE: .github/container/Dockerfile.l2r | |
secrets: inherit | |
arm64: | |
needs: metadata | |
uses: ./.github/workflows/_build.yaml | |
with: | |
ARCHITECTURE: arm64 | |
ARTIFACT_NAME: artifact-l2r-build | |
BADGE_FILENAME: badge-l2r-build | |
BASE_IMAGE: ${{ needs.metadata.outputs.BASE_IMAGE_ARM64 }} | |
BUILD_DATE: ${{ needs.metadata.outputs.BUILD_DATE }} | |
CONTAINER_NAME: l2r | |
DOCKERFILE: .github/container/Dockerfile.l2r | |
secrets: inherit | |
publish-mealkit: | |
needs: [metadata, amd64, arm64] | |
if: false | |
#if: needs.metadata.outputs.PUBLISH == 'true' | |
uses: ./.github/workflows/_publish_container.yaml | |
with: | |
SOURCE_IMAGE: | | |
${{ needs.amd64.outputs.DOCKER_TAG_MEALKIT }} | |
${{ needs.arm64.outputs.DOCKER_TAG_MEALKIT }} | |
TARGET_IMAGE: jax | |
TARGET_TAGS: | | |
type=raw,value=l2r-mealkit,priority=500 | |
type=raw,value=l2r-mealkit-${{ needs.metadata.outputs.BUILD_DATE }},priority=500 | |
publish-final: | |
needs: [metadata, amd64, arm64] | |
if: false | |
#if: needs.metadata.outputs.PUBLISH == 'true' | |
uses: ./.github/workflows/_publish_container.yaml | |
with: | |
SOURCE_IMAGE: | | |
${{ needs.amd64.outputs.DOCKER_TAG_FINAL }} | |
${{ needs.arm64.outputs.DOCKER_TAG_FINAL }} | |
TARGET_IMAGE: jax | |
TARGET_TAGS: | | |
type=raw,value=l2r-latest,priority=1000 | |
type=raw,value=l2r-nightly-${{ needs.metadata.outputs.BUILD_DATE }},priority=900 |