Skip to content

Commit a861c0a

Browse files
committed
Check for existing GodotRust bot reply before posting
1 parent 785f6cf commit a861c0a

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

.github/workflows/build-website.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,36 @@ jobs:
109109
- name: "Deploy to GitHub Pages"
110110
uses: actions/deploy-pages@v4
111111

112-
- name: "Comment on GitHub PR"
112+
# Do not comment again if there's already a bot comment.
113+
# This is usually handled by checking the current state of docs in the repo's "database" file. However, in the first few minutes of
114+
# opening a PR, there may be multiple doc jobs running concurrently.
115+
- name: "Check for existing GodotRust comment"
116+
id: check-comment
113117
if: github.event_name == 'repository_dispatch' && github.event.client_payload.put_status == 'Create' && github.event.client_payload.num != 'master'
118+
run: |
119+
repo="${{ github.event.client_payload.repo }}"
120+
num="${{ github.event.client_payload.num }}"
121+
122+
echo "Check for existing bot comments on PR $num..."
123+
124+
commentsResponse=$(curl -L \
125+
--fail-with-body \
126+
-H "Accept: application/vnd.github+json" \
127+
-H "X-GitHub-Api-Version: 2022-11-28" \
128+
https://api.github.com/repos/godot-rust/$repo/issues/$num/comments)
129+
130+
existingCommentId=$(echo "$commentsResponse" | jq -r '.[] | select(.user.login == "GodotRust") | .id' | head -n1)
131+
132+
if [[ -n "$existingCommentId" ]]; then
133+
echo "Found existing comment from GodotRust user (ID: $existingCommentId). Skip duplicate comment."
134+
echo "skip-comment=true" >> $GITHUB_OUTPUT
135+
else
136+
echo "No existing comment from GodotRust user found. Will post new comment."
137+
echo "skip-comment=false" >> $GITHUB_OUTPUT
138+
fi
139+
140+
- name: "Comment on GitHub PR"
141+
if: github.event_name == 'repository_dispatch' && github.event.client_payload.put_status == 'Create' && github.event.client_payload.num != 'master' && steps.check-comment.outputs.skip-comment == 'false'
114142
run: |
115143
url="${{ github.event.client_payload.docs_full_url }}"
116144
repo="${{ github.event.client_payload.repo }}"

0 commit comments

Comments
 (0)