@@ -109,8 +109,36 @@ jobs:
109
109
- name : " Deploy to GitHub Pages"
110
110
uses : actions/deploy-pages@v4
111
111
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
113
117
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'
114
142
run : |
115
143
url="${{ github.event.client_payload.docs_full_url }}"
116
144
repo="${{ github.event.client_payload.repo }}"
0 commit comments