Skip to content

Commit c350224

Browse files
ci: replace thollander/actions-comment-pull-request with inline gh api (#118)
Co-authored-by: fern-bot <174841662+fern-bot@users.noreply.github.com>
1 parent de695ce commit c350224

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

.github/workflows/preview-docs.yml

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,26 @@ jobs:
7878
fi
7979
8080
- name: Post PR comment
81-
uses: thollander/actions-comment-pull-request@v2.4.3
82-
with:
83-
filePath: comment.md
84-
comment_tag: preview-docs
85-
mode: upsert
81+
env:
82+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83+
PR_NUMBER: ${{ github.event.pull_request.number }}
84+
REPO: ${{ github.repository }}
85+
run: |
86+
MARKER="<!-- fern-preview-docs -->"
87+
{
88+
cat comment.md
89+
printf '\n%s\n' "$MARKER"
90+
} > comment-with-marker.md
91+
92+
# Upsert by looking up an existing comment that carries our hidden marker.
93+
EXISTING_ID=$(gh api --paginate \
94+
"repos/$REPO/issues/$PR_NUMBER/comments" \
95+
--jq "[.[] | select(.body | contains(\"$MARKER\"))][0].id // empty")
96+
97+
jq -Rn --rawfile body comment-with-marker.md '{body: $body}' > payload.json
98+
99+
if [ -n "$EXISTING_ID" ]; then
100+
gh api -X PATCH "repos/$REPO/issues/comments/$EXISTING_ID" --input payload.json
101+
else
102+
gh api -X POST "repos/$REPO/issues/$PR_NUMBER/comments" --input payload.json
103+
fi

0 commit comments

Comments
 (0)