fix: use GraphQL for discussion comments and locking (REST 404)
This commit is contained in:
@@ -124,9 +124,17 @@ jobs:
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (isDiscussion) {
|
if (isDiscussion) {
|
||||||
await github.request('POST /repos/{owner}/{repo}/discussions/{discussion_number}/comments', {
|
const discId = context.payload.discussion.node_id;
|
||||||
owner, repo, discussion_number: number, body: decision.message
|
if (discId) {
|
||||||
});
|
const msg = decision.message.replace(/"/g, '\\"');
|
||||||
|
await github.graphql(`
|
||||||
|
mutation {
|
||||||
|
addDiscussionComment(input: {discussionId: "${discId}", body: "${msg}"}) {
|
||||||
|
comment { id }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await github.rest.issues.addLabels({
|
await github.rest.issues.addLabels({
|
||||||
owner, repo, issue_number: number, labels: ['ai-moderated']
|
owner, repo, issue_number: number, labels: ['ai-moderated']
|
||||||
@@ -152,9 +160,16 @@ jobs:
|
|||||||
|
|
||||||
if (decision.action === 'lock') {
|
if (decision.action === 'lock') {
|
||||||
if (isDiscussion) {
|
if (isDiscussion) {
|
||||||
await github.request('PUT /repos/{owner}/{repo}/discussions/{discussion_number}/lock', {
|
const discId = context.payload.discussion.node_id;
|
||||||
owner, repo, discussion_number: number
|
if (discId) {
|
||||||
});
|
await github.graphql(`
|
||||||
|
mutation {
|
||||||
|
lockLockable(input: {lockableId: "${discId}", lockReason: TOO_HEATED}) {
|
||||||
|
lockedRecord { activeLockReason }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
await github.rest.issues.lock({ owner, repo, issue_number: number, lock_reason: 'too_heated' });
|
await github.rest.issues.lock({ owner, repo, issue_number: number, lock_reason: 'too_heated' });
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user