-
Notifications
You must be signed in to change notification settings - Fork 79
ci: auto-publish model-engine helm chart to public ECR on merge (MLI-7871) #859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
billyang-scale
wants to merge
1
commit into
scaleapi:main
Choose a base branch
from
billyang-scale:billyang/_claude/publish-helm-chart-ci
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+69
−0
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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,43 @@ | ||
| #!/usr/bin/env bash | ||
| # Publish the model-engine Helm chart to the public ECR registry. | ||
| # | ||
| # Idempotent: reads the chart version from charts/model-engine/Chart.yaml and | ||
| # only packages + pushes when that version tag is not already published. So it | ||
| # is safe to run on every merge to main — an actual publish happens only when | ||
| # the chart version was bumped. | ||
| # | ||
| # Requires: helm, aws-cli, and AWS credentials for a principal in account | ||
| # 692474966980 with ecr-public publish permission on | ||
| # model-engine-helm-charts/model-engine (the CircleCI `circleci` OIDC role). | ||
| set -euo pipefail | ||
|
|
||
| CHART_DIR="charts/model-engine" | ||
| PUBLIC_ECR_REGISTRY="public.ecr.aws/b2z8n5q1" | ||
| CHART_REPO_PATH="model-engine-helm-charts" # helm appends the chart name (model-engine) | ||
| ECR_REPOSITORY_NAME="model-engine-helm-charts/model-engine" | ||
| ECR_PUBLIC_REGION="us-east-1" # ECR Public API only exists in us-east-1 | ||
|
|
||
| VERSION="$(helm show chart "${CHART_DIR}" | awk '/^version:/ {print $2}')" | ||
| if [[ -z "${VERSION}" ]]; then | ||
| echo "ERROR: could not determine chart version from ${CHART_DIR}/Chart.yaml" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "model-engine chart version: ${VERSION}" | ||
|
|
||
| if aws ecr-public describe-images \ | ||
| --region "${ECR_PUBLIC_REGION}" \ | ||
| --repository-name "${ECR_REPOSITORY_NAME}" \ | ||
| --image-ids imageTag="${VERSION}" >/dev/null 2>&1; then | ||
| echo "Chart ${VERSION} is already published to ${PUBLIC_ECR_REGISTRY}/${ECR_REPOSITORY_NAME} — nothing to do." | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "Publishing model-engine chart ${VERSION}..." | ||
| aws ecr-public get-login-password --region "${ECR_PUBLIC_REGION}" \ | ||
| | helm registry login --username AWS --password-stdin public.ecr.aws | ||
|
|
||
| PKG_DIR="$(mktemp -d)" | ||
| helm package "${CHART_DIR}" -d "${PKG_DIR}" | ||
| helm push "${PKG_DIR}/model-engine-${VERSION}.tgz" "oci://${PUBLIC_ECR_REGISTRY}/${CHART_REPO_PATH}" | ||
|
|
||
| echo "Published oci://${PUBLIC_ECR_REGISTRY}/${ECR_REPOSITORY_NAME}:${VERSION}" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
describe-imageserrors are fully suppressed (>/dev/null 2>&1), so any failure — permission denied, transient network error, throttling — is interpreted the same way as "image not found" and causes the script to proceed to publish. If the OIDC role gains push permission but is missingecr-public:DescribeImages, the check is effectively bypassed on every run; publishing would succeed on new versions but produce a redundant push attempt on unchanged versions. Consider checking the exit code separately from error output so a non-404 failure can surface rather than silently proceeding.Prompt To Fix With AI