File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments