Skip to content

Commit

Permalink
publish script
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuval Yacoby committed Oct 8, 2023
1 parent 082f67b commit 77e9d12
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cas-deploy/publish-helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

path_to_chart="../k8s/charts/seaweedfs"
repo_name="cas-external-chart-seaweedfs"
chart_name="seaweedfs"
profile="$AWS_PROFILE"
region="$AWS_REGION"
account_id="$AWS_ACCOUNT_ID"
version=$(grep -E 'version' $path_to_chart/Chart.yaml | awk '{print $NF}' | sed 's/://')

sed -i.bak "s/^name: .*/name: $repo_name/" "$path_to_chart/Chart.yaml" && rm -rf "$path_to_chart/chart.yaml.bak"

# mv "$chart_name" "$repo_name"

helm package $path_to_chart

if aws ecr describe-repositories --region $region --profile $profile --repository-names $repo_name > /dev/null 2>&1; then
echo "ECR repository '$repo_name' already exists."
else
aws ecr create-repository \
--repository-name $repo_name \
--region $region \
--profile $profile > /dev/null 2>&1
fi

aws ecr get-login-password \
--profile $profile --region $region | helm registry login \
--username AWS \
--password-stdin $account_id.dkr.ecr.$region.amazonaws.com

helm push $repo_name-$version.tgz oci://$account_id.dkr.ecr.$region.amazonaws.com/
rm -rf $repo_name-$version.tgz
sed -i.bak "s/^name: .*/name: seaweedfs/" "$path_to_chart/Chart.yaml" && rm -rf "$path_to_chart/chart.yaml.bak"
31 changes: 31 additions & 0 deletions cas-deploy/publish-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

repository="chrislusf"
image_name="seaweedfs"
image_version="$SEAWEEDFS_VERSION"
profile="$AWS_PROFILE"
region="$AWS_REGION"
account_id="$AWS_ACCOUNT_ID"

source_image="$repository/$image_name:$image_version"
repo_name="cas-external-image-$image_name"

docker pull "$repository/$image_name:$image_version"

docker tag $source_image $account_id.dkr.ecr.$region.amazonaws.com/$repo_name:$image_version

if aws ecr describe-repositories --region $region --profile $profile --repository-names $repo_name > /dev/null 2>&1; then
echo "ECR repository '$repo_name' already exists."
else
aws ecr create-repository \
--repository-name $repo_name \
--region $region \
--profile $profile > /dev/null 2>&1
fi

aws ecr get-login-password \
--profile $profile --region $region | docker login \
--username AWS \
--password-stdin $account_id.dkr.ecr.$region.amazonaws.com

docker push $account_id.dkr.ecr.$region.amazonaws.com/$repo_name:$image_version

0 comments on commit 77e9d12

Please sign in to comment.