Skip to content

Commit

Permalink
Merge branch 'main' into fix/refactor-env-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nirooxx committed Feb 24, 2025
2 parents 77851f2 + abbb538 commit 840b3de
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion scripts/create-pr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ branch_name="release-changelog-update/${VERSION}"
echo "Cloning workspace to temporary directory: $TEMP_DIR"
cp -r "$GITHUB_WORKSPACE/." "$TEMP_DIR/"
cd "$TEMP_DIR" || exit 1
echo "Cloning workspace to temporary directory: $TEMP_DIR"
cp -r "$GITHUB_WORKSPACE/." "$TEMP_DIR/"
cd "$TEMP_DIR" || exit 1

git fetch origin "$TARGET_BRANCH"

Expand All @@ -28,9 +31,10 @@ fi
if git ls-remote --exit-code --heads origin "$branch_name"; then
git checkout "$branch_name"
git pull --rebase origin "$branch_name" || echo "No updates to rebase."
git pull --rebase origin "$branch_name" || echo "No updates to rebase."
else
echo "Creating new branch: $branch_name"
git checkout -b "$branch_name"
git checkout -b "$branch_name" "origin/$TARGET_BRANCH"
fi

# Stage and commit local changes to avoid issues when switching branches
Expand All @@ -51,6 +55,10 @@ response=$(curl -s -X POST \
echo "::error:: Create a pull request"
exit 1
}
"$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls") || {
echo "::error:: Create a pull request"
exit 1
}

pr_url=$(echo "$response" | jq -r '.html_url // empty')

Expand All @@ -64,6 +72,9 @@ export PR_URL="$pr_url"
cd "$GITHUB_WORKSPACE"
rm -rf "$TEMP_DIR"

cd "$GITHUB_WORKSPACE"
rm -rf "$TEMP_DIR"

# Notify the user about the created PR
echo "::notice::A pull request has been created for the changelog update."
echo "::notice::PR URL: $PR_URL"
Expand Down

0 comments on commit 840b3de

Please sign in to comment.