Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 33 additions & 7 deletions .github/workflows/ngwpc-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ on:
- main
- nwm-main
- development
- development-pw
- release-candidate
push:
branches:
Expand All @@ -16,6 +17,7 @@ on:
- main
- nwm-main
- development
- development-pw
- release-candidate
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -80,6 +82,7 @@ jobs:
alias_tag: ${{ steps.vars.outputs.alias_tag }}
clean_ref: ${{ steps.vars.outputs.clean_ref }}
default_ref: ${{ steps.vars.outputs.default_ref }}
default_base_tag: ${{ steps.vars.outputs.default_base_tag }}
ngen_forcing_digest: ${{ steps.vars.outputs.ngen_forcing_digest }}
ngen_forcing_revision: ${{ steps.vars.outputs.ngen_forcing_revision }}
ewts_revision: ${{ steps.vars.outputs.ewts_revision }}
Expand Down Expand Up @@ -115,17 +118,28 @@ jobs:
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.
# (development / development-pw / 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)
branch:development|branch:development-pw|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"; }

# base-image alias follows the lane: development-pw (or a PR into it) pulls
# the rocky 'latest-pw' alias, every other ref the bookworm 'latest'. An
# explicit NGEN_FORCING_IMAGE_TAG input always wins over this default.
LANE_REF="${GITHUB_BASE_REF:-$GITHUB_REF_NAME}"
if [ "$LANE_REF" = "development-pw" ]; then
DEFAULT_BASE_TAG="latest-pw"
else
DEFAULT_BASE_TAG="latest"
fi

# 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
Expand All @@ -151,7 +165,8 @@ jobs:
fi

# base image (ngen-forcing) metadata for ngen Dockerfile labels
NGEN_FORCING_IMAGE_TAG="${{ inputs.NGEN_FORCING_IMAGE_TAG || 'latest' }}"
NGEN_FORCING_IMAGE_TAG="${{ inputs.NGEN_FORCING_IMAGE_TAG }}"
NGEN_FORCING_IMAGE_TAG="${NGEN_FORCING_IMAGE_TAG:-$DEFAULT_BASE_TAG}"
NGEN_FORCING_IMAGE="ghcr.io/${ORG}/ngen-bmi-forcing:${NGEN_FORCING_IMAGE_TAG}"
NGEN_FORCING_INSPECT=$(skopeo inspect --override-os linux --override-arch amd64 "docker://${NGEN_FORCING_IMAGE}" 2>/dev/null || echo '{}')
NGEN_FORCING_DIGEST=$(echo "$NGEN_FORCING_INSPECT" | jq -r '.Digest // "unknown"')
Expand Down Expand Up @@ -184,6 +199,7 @@ jobs:
commit_sha_short=${SHORT_SHA}
clean_ref=${CLEAN_REF}
default_ref=${DEFAULT_REF}
default_base_tag=${DEFAULT_BASE_TAG}
ngen_forcing_digest=${NGEN_FORCING_DIGEST}
ngen_forcing_revision=${NGEN_FORCING_REVISION}
ewts_revision=${EWTS_REVISION}
Expand Down Expand Up @@ -259,7 +275,7 @@ jobs:
tags: ${{ needs.setup.outputs.image_base }}:${{ needs.setup.outputs.test_image_tag }}
build-args: |
GHCR_ORG=${{ inputs.GHCR_ORG || needs.setup.outputs.org }}
FORCING_IMAGE=ghcr.io/${{ needs.setup.outputs.org }}/ngen-bmi-forcing:${{ inputs.NGEN_FORCING_IMAGE_TAG || 'latest' }}
FORCING_IMAGE=ghcr.io/${{ needs.setup.outputs.org }}/ngen-bmi-forcing:${{ inputs.NGEN_FORCING_IMAGE_TAG || needs.setup.outputs.default_base_tag }}
FORCING_IMAGE_DIGEST=${{ needs.setup.outputs.ngen_forcing_digest }}
FORCING_IMAGE_REVISION=${{ needs.setup.outputs.ngen_forcing_revision }}
EWTS_ORG=${{ inputs.EWTS_ORG || github.repository_owner }}
Expand Down Expand Up @@ -368,21 +384,31 @@ jobs:
--all \
"docker://${IMAGE_BASE}:${TEST_TAG}" "docker://${IMAGE_BASE}:${ALIAS_TAG}"

# tag with 'latest' on development branch
# Branch-keyed promotion: development promotes 'latest' (bookworm/AWS
# lane); development-pw promotes 'latest-pw' (rocky/PW lane). Do not
# manually dispatch a cross-lane build from either branch: promotion
# keys off the branch name, so the tested image would promote under
# the wrong alias.
if [ "$GITHUB_REF_NAME" = "development" ]; then
skopeo copy \
--src-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
--dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
--all \
"docker://${IMAGE_BASE}:${TEST_TAG}" "docker://${IMAGE_BASE}:latest"
elif [ "$GITHUB_REF_NAME" = "development-pw" ]; then
skopeo copy \
--src-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
--dest-creds "${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}" \
--all \
"docker://${IMAGE_BASE}:${TEST_TAG}" "docker://${IMAGE_BASE}:latest-pw"
fi

# trigger downstream repos, nwm-cal-mgr and nwm-fcst-mgr
trigger-downstream:
name: trigger-downstream (${{ matrix.repo }})
if: |
success() && (
(github.event_name == 'push' && (github.ref_name == 'development' || github.ref_name == 'ngwpc-candidate' || github.ref_name == 'ngwpc-release')) ||
(github.event_name == 'push' && (github.ref_name == 'development' || github.ref_name == 'development-pw' || github.ref_name == 'ngwpc-candidate' || github.ref_name == 'ngwpc-release')) ||
(github.event_name == 'workflow_dispatch' && inputs.TRIGGER_DOWNSTREAM)
)
runs-on: ubuntu-latest
Expand Down
Loading