|
| 1 | +# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: BSD-3-Clause |
| 5 | + |
| 6 | +name: Publish Docker Images |
| 7 | + |
| 8 | +on: |
| 9 | + # Nightly build + publish from develop and the active release branches listed |
| 10 | + # in CRON_BRANCHES below. No push triggers — workflow_dispatch also accepts any |
| 11 | + # publishable branch. main is intentionally excluded: main images are built |
| 12 | + # by postmerge-ci.yml on push instead. |
| 13 | + schedule: |
| 14 | + - cron: '0 2 * * *' # 6pm PST / 7pm PDT |
| 15 | + workflow_dispatch: |
| 16 | + inputs: |
| 17 | + branch: |
| 18 | + description: 'Branch to build and publish (e.g. develop, release/3.0.0-beta2)' |
| 19 | + required: true |
| 20 | + type: string |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + |
| 25 | +# Branches the nightly cron publishes. Single source of truth — append a ref |
| 26 | +# here when a new release/* is cut and drop it once that release is retired, so |
| 27 | +# stale branches aren't rebuilt nightly. Mirrors CRON_BRANCHES in |
| 28 | +# nightly-changelog.yml. Whitespace per entry is stripped. main is excluded on |
| 29 | +# purpose (it builds on the public isaac-sim base via postmerge-ci.yml). |
| 30 | +env: |
| 31 | + NGC_API_KEY: ${{ secrets.NGC_API_KEY }} |
| 32 | + CRON_BRANCHES: develop,release/3.0.0-beta2 |
| 33 | + |
| 34 | +jobs: |
| 35 | + resolve-branches: |
| 36 | + name: Resolve publish branches |
| 37 | + runs-on: ubuntu-latest |
| 38 | + timeout-minutes: 1 |
| 39 | + outputs: |
| 40 | + branches: ${{ steps.b.outputs.branches }} |
| 41 | + steps: |
| 42 | + - id: b |
| 43 | + env: |
| 44 | + # Schedule → the CRON_BRANCHES list. Manual → the single branch the |
| 45 | + # maintainer entered (required input). Same pattern as nightly-changelog.yml. |
| 46 | + BRANCHES: ${{ github.event_name == 'schedule' && env.CRON_BRANCHES || inputs.branch }} |
| 47 | + run: | |
| 48 | + # CSV → newline, trimming surrounding whitespace per entry, then to a |
| 49 | + # compact JSON array. Manual produces a 1-element array; cron N elements. |
| 50 | + arr=$(echo "$BRANCHES" | tr ',' '\n' | xargs -n1 | jq -R . | jq -s -c .) |
| 51 | + if [ "$(echo "$arr" | jq 'length')" -eq 0 ]; then |
| 52 | + echo "::error::No branches resolved for publishing" |
| 53 | + exit 1 |
| 54 | + fi |
| 55 | + echo "branches=$arr" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Resolved branches: $arr" |
| 57 | +
|
| 58 | + config: |
| 59 | + name: Load Config |
| 60 | + runs-on: ubuntu-latest |
| 61 | + outputs: |
| 62 | + isaacsim_image_name: ${{ steps.load.outputs.isaacsim_image_name }} |
| 63 | + isaacsim_image_tag: ${{ steps.load.outputs.isaacsim_image_tag }} |
| 64 | + isaaclab_image_name: ${{ steps.load.outputs.isaaclab_image_name }} |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v6 |
| 67 | + with: |
| 68 | + fetch-depth: 1 |
| 69 | + sparse-checkout: .github/workflows/config.yaml |
| 70 | + sparse-checkout-cone-mode: false |
| 71 | + - id: load |
| 72 | + run: | |
| 73 | + set -euo pipefail |
| 74 | + f=.github/workflows/config.yaml |
| 75 | + echo "isaacsim_image_name=$(yq -r .isaacsim_image_name "$f")" >> "$GITHUB_OUTPUT" |
| 76 | + echo "isaacsim_image_tag=$(yq -r .isaacsim_image_tag "$f")" >> "$GITHUB_OUTPUT" |
| 77 | + echo "isaaclab_image_name=$(yq -r .isaaclab_image_name "$f")" >> "$GITHUB_OUTPUT" |
| 78 | +
|
| 79 | + build-and-push-images: |
| 80 | + name: Build and Push (${{ matrix.branch }}) |
| 81 | + needs: [config, resolve-branches] |
| 82 | + runs-on: [self-hosted, gpu] |
| 83 | + timeout-minutes: 180 |
| 84 | + strategy: |
| 85 | + fail-fast: false |
| 86 | + matrix: |
| 87 | + branch: ${{ fromJson(needs.resolve-branches.outputs.branches) }} |
| 88 | + concurrency: |
| 89 | + group: publish-images-${{ matrix.branch }} |
| 90 | + cancel-in-progress: true |
| 91 | + environment: |
| 92 | + name: postmerge-production |
| 93 | + url: https://github.com/${{ github.repository }} |
| 94 | + env: |
| 95 | + DOCKER_HOST: unix:///var/run/docker.sock |
| 96 | + DOCKER_TLS_CERTDIR: "" |
| 97 | + |
| 98 | + steps: |
| 99 | + - name: Checkout Code |
| 100 | + uses: actions/checkout@v6 |
| 101 | + with: |
| 102 | + fetch-depth: 1 |
| 103 | + lfs: true |
| 104 | + ref: ${{ matrix.branch }} |
| 105 | + |
| 106 | + - name: Set up QEMU |
| 107 | + uses: docker/setup-qemu-action@v3 |
| 108 | + with: |
| 109 | + platforms: linux/arm64 |
| 110 | + |
| 111 | + - name: Set up Docker Buildx |
| 112 | + uses: docker/setup-buildx-action@v3 |
| 113 | + with: |
| 114 | + platforms: linux/amd64,linux/arm64 |
| 115 | + driver-opts: | |
| 116 | + image=moby/buildkit:buildx-stable-1 |
| 117 | +
|
| 118 | + - name: Login to NGC |
| 119 | + run: | |
| 120 | + # Only attempt NGC login if API key is available |
| 121 | + if [ -n "$NGC_API_KEY" ]; then |
| 122 | + echo "🔵 Logging into NGC registry..." |
| 123 | + if ! echo "$NGC_API_KEY" | docker login -u '$oauthtoken' --password-stdin nvcr.io; then |
| 124 | + echo "🔴 Failed to log into NGC registry" |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | + echo "🟢 Successfully logged into NGC registry" |
| 128 | + else |
| 129 | + echo "🟠 NGC_API_KEY not set - skipping NGC login (normal when secrets are not configured)" |
| 130 | + fi |
| 131 | +
|
| 132 | + - name: Build and Push Docker Images |
| 133 | + run: | |
| 134 | + BRANCH_NAME="${{ matrix.branch }}" |
| 135 | + IMAGE_BASE_VERSION="${{ needs.config.outputs.isaacsim_image_tag }}" |
| 136 | + IMAGE="${{ needs.config.outputs.isaaclab_image_name }}" |
| 137 | +
|
| 138 | + # Use the SHA actually checked out for this branch (the matrix ref), not |
| 139 | + # github.sha — on a scheduled run github.sha is the default branch (main) |
| 140 | + # HEAD, which would mis-tag every nightly image. |
| 141 | + FULL_SHA="$(git rev-parse HEAD)" |
| 142 | +
|
| 143 | + echo "Branch: $BRANCH_NAME" |
| 144 | + echo "Commit: $FULL_SHA" |
| 145 | + echo "IsaacSim base image: ${{ needs.config.outputs.isaacsim_image_name }}:$IMAGE_BASE_VERSION" |
| 146 | + echo "Target Isaac Lab image: $IMAGE" |
| 147 | +
|
| 148 | + # Build the tag list for the branch (main is published separately via |
| 149 | + # postmerge-ci.yml, so it is not handled here). |
| 150 | + # |
| 151 | + # Tagging scheme: |
| 152 | + # - develop: $IMAGE:latest-develop (moves to newest develop build) |
| 153 | + # $IMAGE:latest-develop-<full-sha> (immutable per-commit) |
| 154 | + # - release/X: $IMAGE:latest-release-X (moves to newest build on that release branch) |
| 155 | + # $IMAGE:latest-release-X-<full-sha> (immutable per-commit) |
| 156 | + # |
| 157 | + # The immutable per-commit tag doubles as the "already published" marker: |
| 158 | + # if it exists in the registry the branch has not advanced since the last |
| 159 | + # publish, so the nightly build is skipped (see the guard below). |
| 160 | + MOVING_TAG="" |
| 161 | + IMMUTABLE_TAG="" |
| 162 | +
|
| 163 | + case "$BRANCH_NAME" in |
| 164 | + develop) |
| 165 | + MOVING_TAG="$IMAGE:latest-develop" |
| 166 | + IMMUTABLE_TAG="$IMAGE:latest-develop-$FULL_SHA" |
| 167 | + ;; |
| 168 | + release/*) |
| 169 | + # Sanitize the part after release/ for use as a Docker tag suffix. |
| 170 | + RELEASE_SUFFIX=$(echo "${BRANCH_NAME#release/}" | sed 's/[^a-zA-Z0-9._-]/-/g') |
| 171 | + MOVING_TAG="$IMAGE:latest-release-$RELEASE_SUFFIX" |
| 172 | + IMMUTABLE_TAG="$IMAGE:latest-release-$RELEASE_SUFFIX-$FULL_SHA" |
| 173 | + ;; |
| 174 | + main) |
| 175 | + # main is intentionally not published here; see postmerge-ci.yml for main. |
| 176 | + echo "Branch 'main' is not published by this workflow; skipping. See postmerge-ci.yml for main." |
| 177 | + exit 0 |
| 178 | + ;; |
| 179 | + *) |
| 180 | + echo "Branch '$BRANCH_NAME' is not configured for publishing; skipping." |
| 181 | + exit 0 |
| 182 | + ;; |
| 183 | + esac |
| 184 | +
|
| 185 | + # Skip the (expensive) build when this exact commit was already published. |
| 186 | + # The immutable per-commit tag is the source of truth for "git advanced": |
| 187 | + # if it already exists in the registry, nothing new to build for this branch. |
| 188 | + if docker manifest inspect "$IMMUTABLE_TAG" >/dev/null 2>&1; then |
| 189 | + echo "🟢 $IMMUTABLE_TAG already exists — $BRANCH_NAME has not advanced since the last publish. Skipping." |
| 190 | + exit 0 |
| 191 | + fi |
| 192 | +
|
| 193 | + TAGS=("$MOVING_TAG" "$IMMUTABLE_TAG") |
| 194 | +
|
| 195 | + # Determine if multiarch is supported by inspecting the base image manifest |
| 196 | + echo "🔵 Checking if base image supports multiarch..." |
| 197 | + BASE_IMAGE_FULL="${{ needs.config.outputs.isaacsim_image_name }}:${IMAGE_BASE_VERSION}" |
| 198 | + ARCHITECTURES=$(docker manifest inspect "$BASE_IMAGE_FULL" 2>/dev/null | grep -o '"architecture": "[^"]*"' | cut -d'"' -f4 | sort -u) |
| 199 | +
|
| 200 | + if [ -z "$ARCHITECTURES" ]; then |
| 201 | + echo "🟠 Could not inspect base image manifest: $BASE_IMAGE_FULL - defaulting to linux/amd64 only" |
| 202 | + BUILD_PLATFORMS="linux/amd64" |
| 203 | + else |
| 204 | + echo "Base image architectures found:" |
| 205 | + echo "$ARCHITECTURES" | sed 's/^/ - /' |
| 206 | +
|
| 207 | + HAS_AMD64=$(echo "$ARCHITECTURES" | grep -c "amd64" || true) |
| 208 | + HAS_ARM64=$(echo "$ARCHITECTURES" | grep -c "arm64" || true) |
| 209 | +
|
| 210 | + if [ "$HAS_AMD64" -gt 0 ] && [ "$HAS_ARM64" -gt 0 ]; then |
| 211 | + echo "🟢 Base image supports multiarch (amd64 + arm64)" |
| 212 | + BUILD_PLATFORMS="linux/amd64,linux/arm64" |
| 213 | + elif [ "$HAS_AMD64" -gt 0 ]; then |
| 214 | + echo "Base image only supports amd64" |
| 215 | + BUILD_PLATFORMS="linux/amd64" |
| 216 | + elif [ "$HAS_ARM64" -gt 0 ]; then |
| 217 | + echo "Base image only supports arm64" |
| 218 | + BUILD_PLATFORMS="linux/arm64" |
| 219 | + else |
| 220 | + echo "🟠 Unknown architecture support for $BASE_IMAGE_FULL - defaulting to linux/amd64" |
| 221 | + BUILD_PLATFORMS="linux/amd64" |
| 222 | + fi |
| 223 | + fi |
| 224 | +
|
| 225 | + echo "Target platforms: $BUILD_PLATFORMS" |
| 226 | + echo "Tags to publish:" |
| 227 | + printf ' - %s\n' "${TAGS[@]}" |
| 228 | +
|
| 229 | + # Compose -t flags for buildx |
| 230 | + TAG_ARGS=() |
| 231 | + for t in "${TAGS[@]}"; do |
| 232 | + TAG_ARGS+=("-t" "$t") |
| 233 | + done |
| 234 | +
|
| 235 | + echo "🔵 Building and pushing image with tags listed above..." |
| 236 | + if ! docker buildx build \ |
| 237 | + --platform "$BUILD_PLATFORMS" \ |
| 238 | + --progress=plain \ |
| 239 | + "${TAG_ARGS[@]}" \ |
| 240 | + --build-arg ISAACSIM_BASE_IMAGE_ARG=${{ needs.config.outputs.isaacsim_image_name }} \ |
| 241 | + --build-arg ISAACSIM_VERSION_ARG="$IMAGE_BASE_VERSION" \ |
| 242 | + --build-arg ISAACSIM_ROOT_PATH_ARG=/isaac-sim \ |
| 243 | + --build-arg ISAACLAB_PATH_ARG=/workspace/isaaclab \ |
| 244 | + --build-arg DOCKER_USER_HOME_ARG=/root \ |
| 245 | + --cache-from type=gha \ |
| 246 | + --cache-to type=gha,mode=max \ |
| 247 | + -f docker/Dockerfile.base \ |
| 248 | + --push .; then |
| 249 | + echo "🔴 docker buildx build/push failed for tags:" |
| 250 | + printf ' - %s\n' "${TAGS[@]}" |
| 251 | + exit 1 |
| 252 | + fi |
| 253 | +
|
| 254 | + for t in "${TAGS[@]}"; do |
| 255 | + echo "🟢 Successfully built and pushed: $t (platforms: $BUILD_PLATFORMS)" |
| 256 | + done |
0 commit comments