From 5a26032ba0f874013205cbf9e6743eb1463388ba Mon Sep 17 00:00:00 2001 From: Miguel Pena Date: Tue, 19 May 2026 20:40:21 -0700 Subject: [PATCH 1/2] ci updates --- .github/workflows/ci-cd.yml | 43 ++++++++++++++++++++++++++++--------- Dockerfile | 14 +++++++++--- 2 files changed, 44 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7d2ff42..310bc36 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -69,6 +69,8 @@ jobs: clean_ref: ${{ steps.vars.outputs.clean_ref }} ngen_image_digest: ${{ steps.vars.outputs.ngen_image_digest }} ngen_image_revision: ${{ steps.vars.outputs.ngen_image_revision }} + ewts_revision: ${{ steps.vars.outputs.ewts_revision }} + msw_mgr_revision: ${{ steps.vars.outputs.msw_mgr_revision }} steps: - name: Compute image vars id: vars @@ -127,20 +129,39 @@ jobs: # base image (ngen) metadata for Dockerfile labels NGEN_IMAGE_TAG="${{ inputs.NGEN_IMAGE_TAG || 'latest' }}" NGEN_IMAGE="ghcr.io/${ORG}/ngen:${NGEN_IMAGE_TAG}" - NGEN_INSPECT=$(skopeo inspect "docker://${NGEN_IMAGE}" 2>/dev/null || echo '{}') + NGEN_INSPECT=$(skopeo inspect --override-os linux --override-arch amd64 "docker://${NGEN_IMAGE}" 2>/dev/null || echo '{}') NGEN_IMAGE_DIGEST=$(echo "$NGEN_INSPECT" | jq -r '.Digest // "unknown"') NGEN_IMAGE_REVISION=$(echo "$NGEN_INSPECT" | jq -r '.Labels["org.opencontainers.image.revision"] // "unknown"') + # resolve each source repo's ref (branch/tag/SHA) to its commit SHA for revision labels + resolve_sha() { + local url="$1" ref="$2" out sha + # a full 40-char SHA can't be looked up via ls-remote; use it directly + if [[ "$ref" =~ ^[0-9a-f]{40}$ ]]; then echo "$ref"; return; fi + out=$(git ls-remote "$url" "$ref" "refs/tags/${ref}^{}" 2>/dev/null) + # prefer the dereferenced commit (^{}) for annotated tags; else first match + sha=$(echo "$out" | grep '\^{}$' | head -n1 | cut -f1) + [ -z "$sha" ] && sha=$(echo "$out" | head -n1 | cut -f1) + echo "${sha:-unknown}" + } + + EWTS_REVISION=$(resolve_sha "https://github.com/${{ inputs.EWTS_ORG || github.repository_owner }}/nwm-ewts.git" "${{ inputs.EWTS_REF || 'development' }}") + MSW_MGR_REVISION=$(resolve_sha "https://github.com/${{ inputs.MSW_MGR_ORG || github.repository_owner }}/nwm-msw-mgr.git" "${{ inputs.MSW_MGR_REF || 'development' }}") + # save outputs - echo "org=${ORG}" >> "$GITHUB_OUTPUT" - echo "image_base=${IMAGE_BASE}" >> "$GITHUB_OUTPUT" - echo "test_image_tag=${TEST_TAG}" >> "$GITHUB_OUTPUT" - echo "alias_tag=${ALIAS}" >> "$GITHUB_OUTPUT" - echo "commit_sha=${REAL_SHA}" >> "$GITHUB_OUTPUT" - echo "commit_sha_short=${SHORT_SHA}" >> "$GITHUB_OUTPUT" - echo "clean_ref=${CLEAN_REF}" >> "$GITHUB_OUTPUT" - echo "ngen_image_digest=${NGEN_IMAGE_DIGEST}" >> "$GITHUB_OUTPUT" - echo "ngen_image_revision=${NGEN_IMAGE_REVISION}" >> "$GITHUB_OUTPUT" + cat >> "$GITHUB_OUTPUT" < Date: Tue, 19 May 2026 21:32:10 -0700 Subject: [PATCH 2/2] ci updates --- .github/workflows/ci-cd.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 310bc36..959797e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -67,6 +67,7 @@ jobs: test_image_tag: ${{ steps.vars.outputs.test_image_tag }} alias_tag: ${{ steps.vars.outputs.alias_tag }} clean_ref: ${{ steps.vars.outputs.clean_ref }} + default_ref: ${{ steps.vars.outputs.default_ref }} ngen_image_digest: ${{ steps.vars.outputs.ngen_image_digest }} ngen_image_revision: ${{ steps.vars.outputs.ngen_image_revision }} ewts_revision: ${{ steps.vars.outputs.ewts_revision }} @@ -102,6 +103,18 @@ jobs: CLEAN_REF=$(echo "$REAL_REF" | tr '[:upper:]' '[:lower:]' | sed 's/\//-/g') SHORT_SHA="${REAL_SHA:0:7}" + # default source-repo ref: follow the release-line branch we're building from + # (development / ngwpc-candidate / ngwpc-release); tags and other branches fall + # back to development. Override per source repo via the *_REF dispatch inputs. + case "${GITHUB_REF_TYPE}:${GITHUB_REF_NAME}" in + branch:development|branch:ngwpc-candidate|branch:ngwpc-release) + DEFAULT_REF="$GITHUB_REF_NAME" ;; + *) + DEFAULT_REF="development" ;; + esac + # use an explicit *_REF input if provided, else DEFAULT_REF + ref_or_default() { [ -n "$1" ] && echo "$1" || echo "$DEFAULT_REF"; } + # logic for the tags: # test_image_tag (commit short sha): used for the initial build and test # alias_tag: used for final tagging on successful tests @@ -145,8 +158,8 @@ jobs: echo "${sha:-unknown}" } - EWTS_REVISION=$(resolve_sha "https://github.com/${{ inputs.EWTS_ORG || github.repository_owner }}/nwm-ewts.git" "${{ inputs.EWTS_REF || 'development' }}") - MSW_MGR_REVISION=$(resolve_sha "https://github.com/${{ inputs.MSW_MGR_ORG || github.repository_owner }}/nwm-msw-mgr.git" "${{ inputs.MSW_MGR_REF || 'development' }}") + EWTS_REVISION=$(resolve_sha "https://github.com/${{ inputs.EWTS_ORG || github.repository_owner }}/nwm-ewts.git" "$(ref_or_default "${{ inputs.EWTS_REF }}")") + MSW_MGR_REVISION=$(resolve_sha "https://github.com/${{ inputs.MSW_MGR_ORG || github.repository_owner }}/nwm-msw-mgr.git" "$(ref_or_default "${{ inputs.MSW_MGR_REF }}")") # save outputs cat >> "$GITHUB_OUTPUT" <