File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77permissions :
88 contents : read
99 pull-requests : read
10+ issues : write
1011
1112jobs :
1213 governance :
5354 if : always()
5455 run : |
5556 cat agent_governance_summary.md >> "$GITHUB_STEP_SUMMARY"
57+
58+ - name : Comment governance warnings
59+ if : >-
60+ always() &&
61+ github.event.pull_request.head.repo.full_name == github.repository
62+ env :
63+ GH_TOKEN : ${{ github.token }}
64+ PR_NUMBER : ${{ github.event.pull_request.number }}
65+ run : |
66+ if ! grep -qi '^| warning |' agent_governance_summary.md; then
67+ exit 0
68+ fi
69+
70+ marker='<!-- agent-governance-warning -->'
71+ body_file="$(mktemp)"
72+ json_file="$(mktemp)"
73+ {
74+ echo "$marker"
75+ echo
76+ cat agent_governance_summary.md
77+ } > "$body_file"
78+ jq -Rs '{body: .}' < "$body_file" > "$json_file"
79+
80+ existing_comment_id="$(gh api --paginate \
81+ "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
82+ --jq ".[] | select(.body | contains(\"${marker}\")) | .id" \
83+ | head -n 1)"
84+
85+ if [ -n "$existing_comment_id" ]; then
86+ gh api --method PATCH \
87+ "repos/${GITHUB_REPOSITORY}/issues/comments/${existing_comment_id}" \
88+ --input "$json_file"
89+ else
90+ gh api --method POST \
91+ "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
92+ --input "$json_file"
93+ fi
You can’t perform that action at this time.
0 commit comments