This repository was archived by the owner on Jun 12, 2025. It is now read-only.
forked from openmeterio/openmeter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush_to_ecr.sh
More file actions
executable file
·87 lines (71 loc) · 2.74 KB
/
push_to_ecr.sh
File metadata and controls
executable file
·87 lines (71 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/bin/bash
set -e
REPOSITORY="scispace/openmeter-helm"
AWS_REGION=us-west-2
ECR_REGISTRY="249531194221.dkr.ecr.$AWS_REGION.amazonaws.com"
CREATE_LATEST=false
# Parse command line arguments
for arg in "$@"; do
if [ "$arg" = "--enable-latest" ]; then
CREATE_LATEST=true
fi
done
# Read version and templates
VERSION=$(cat version)
TAG_TEMPLATE=$(cat tag-templates/version-tag-template)
LATEST_TAG_TEMPLATE=$(cat tag-templates/latest-tag-template)
if [ -z "$VERSION" ] || [ -z "$TAG_TEMPLATE" ] || [ -z "$LATEST_TAG_TEMPLATE" ]; then
echo "Error: Could not find version, version template, or latest tag template"
exit 1
fi
# Replace version in template
VERSION_TAG=${TAG_TEMPLATE/\{VERSION\}/$VERSION}
LATEST_TAG=$LATEST_TAG_TEMPLATE
echo "Deploying Helm chart version $VERSION using templates:"
echo " Version tag: $VERSION_TAG"
if [ "$CREATE_LATEST" = true ]; then
echo " Latest tag: $LATEST_TAG"
echo "Latest tag will be pushed (--enable-latest flag provided)"
else
echo "Latest tag will not be pushed (use --enable-latest flag to push it)"
fi
# Check if chart packages exist
TAGGED_PACKAGE="deploy/charts/${REPOSITORY//\//-}-$VERSION_TAG.tgz"
LATEST_PACKAGE="deploy/charts/${REPOSITORY//\//-}-$LATEST_TAG.tgz"
if [ ! -f "$TAGGED_PACKAGE" ]; then
echo "Error: Chart package $TAGGED_PACKAGE not found"
echo "Please run ./build.sh first"
exit 1
fi
if [ "$CREATE_LATEST" = true ] && [ ! -f "$LATEST_PACKAGE" ]; then
echo "Error: Latest chart package $LATEST_PACKAGE not found"
echo "Please run ./build.sh --enable-latest first"
exit 1
fi
# Authenticate with AWS ECR
echo "Logging into AWS ECR..."
aws ecr get-login-password --region $AWS_REGION | helm registry login $ECR_REGISTRY --username AWS --password-stdin
# Create ECR repository if it doesn't exist
echo "Ensuring ECR repository exists..."
aws ecr describe-repositories --repository-names $REPOSITORY --region $AWS_REGION 2>/dev/null || \
aws ecr create-repository --repository-name $REPOSITORY --region $AWS_REGION
# Push version-specific chart
echo "Pushing version-specific chart..."
helm push "$TAGGED_PACKAGE" "oci://$ECR_REGISTRY"
# Push latest chart if requested
if [ "$CREATE_LATEST" = true ]; then
echo "Pushing latest chart..."
helm push "$LATEST_PACKAGE" "oci://$ECR_REGISTRY"
fi
echo "Deploy completed successfully!"
echo "Charts pushed to ECR:"
echo " - oci://$ECR_REGISTRY/$REPOSITORY:$VERSION_TAG"
if [ "$CREATE_LATEST" = true ]; then
echo " - oci://$ECR_REGISTRY/$REPOSITORY:$LATEST_TAG"
fi
echo ""
echo "To install from ECR, use:"
echo " helm install openmeter oci://$ECR_REGISTRY/$REPOSITORY --version $VERSION_TAG"
if [ "$CREATE_LATEST" = true ]; then
echo " helm install openmeter oci://$ECR_REGISTRY/$REPOSITORY --version $LATEST_TAG"
fi