Skip to content

Commit

Permalink
chore: code:
Browse files Browse the repository at this point in the history
  • Loading branch information
sagarnaikjuspay committed Jan 10, 2024
1 parent 2c427e6 commit 2ddce99
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/link-pr-to-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ jobs:
api_url="https://api.github.com/repos/${{ github.repository }}/pulls/${pr_number}"
current_description=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "$api_url" | jq -r '.body')
updated_description="This PR is linked to the issue #${issue_number}: ${pr_url}\n\n$current_description"
# Retrieve existing comments
existing_comments=$(curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/${issue_number}/comments")
# Debug: Print the updated description
echo "Updated Description: $updated_description"
# Extract existing comment bodies and concatenate with the new comment
all_comments=$(echo "$existing_comments" | jq -r '.[].body' | echo "$new_comment" && cat)
# Update the PR description
# Update comments with the new concatenated comments
api_url="https://api.github.com/repos/${{ github.repository }}/issues/${issue_number}/comments"
curl -sS -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-X PATCH \
-d "{\"body\":\"$updated_description\"}" \
-X POST \
-d "{\"body\":\"$all_comments\"}" \
"$api_url"

0 comments on commit 2ddce99

Please sign in to comment.