From d309c966f3d88d119074eb085e5ee5f88a825334 Mon Sep 17 00:00:00 2001 From: Danil Grigorev Date: Tue, 20 Feb 2024 15:42:15 +0100 Subject: [PATCH] Automatically open PR after make update-helm-plugin-repo Signed-off-by: Danil Grigorev --- hack/publish-index-changes.sh | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 hack/publish-index-changes.sh diff --git a/hack/publish-index-changes.sh b/hack/publish-index-changes.sh new file mode 100755 index 000000000..39bbcbab7 --- /dev/null +++ b/hack/publish-index-changes.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +if [ $# -ne 1 ]; then + echo "Usage: $0 RELEASE_TAG" + exit 1 +fi + +RELEASE_TAG="$1" +BRANCH_NAME="index-${RELEASE_TAG}" +COMMIT_MESSAGE="This PR updates index.yaml for ${RELEASE_TAG}. Automatically generated by make update-helm-repo." +PR_TITLE="🌱 Update helm chart index.yaml to ${RELEASE_TAG}" +PR_DESCRIPTION="**What this PR does / why we need it:**\n\nThis PR updates index.yaml for ${RELEASE_TAG}. Automatically generated by \`make update-helm-repo\`." + +# Checkout index-${RELEASE_TAG} branch +git checkout -b "${BRANCH_NAME}" + +# Add files to commit +git add plugins/clusterctl-operator.yaml index.yaml + +# Commit changes with appropriate message +git commit -m "${COMMIT_MESSAGE}" + +# Push changes to origin +git push origin "${BRANCH_NAME}" + +if ! command -v gh &> /dev/null +then + echo "GitHub CLI (gh) is not installed." + echo "Please open a pull request with the following details:" + echo "Title: $PR_TITLE" + echo -e "Description: \n$PR_DESCRIPTION" + exit 0 +fi + +# Open a PR with title and description +gh pr create --title "${PR_TITLE}" --body "${PR_DESCRIPTION}"