-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lock or unlock issue or pull-request (#317)
Pull Request for #308 Related: - https://octokit.github.io/rest.js/v18#issues-lock - https://octokit.github.io/rest.js/v18#issues-unlock - https://github.com/octokit/webhooks.js/blob/master/src/generated/event-payloads.ts - https://github.com/octokit/types.ts
- Loading branch information
Showing
4 changed files
with
140 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import {context} from '@actions/github'; | ||
import {GitHub} from '@actions/github/lib/utils'; | ||
|
||
export async function closeIssue( | ||
githubClient: InstanceType<typeof GitHub>, | ||
issueNumber: number | ||
): Promise<void> { | ||
await githubClient.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber, | ||
state: 'closed' | ||
}); | ||
return; | ||
} | ||
|
||
export async function openIssue( | ||
githubClient: InstanceType<typeof GitHub>, | ||
issueNumber: number | ||
): Promise<void> { | ||
await githubClient.issues.update({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber, | ||
state: 'open' | ||
}); | ||
return; | ||
} | ||
|
||
export async function lockIssue( | ||
githubClient: InstanceType<typeof GitHub>, | ||
issueNumber: number, | ||
lockReason?: string | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
): Promise<any> { | ||
const reason = (() => { | ||
switch (lockReason) { | ||
case 'off-topic': | ||
return 'off-topic'; | ||
case 'too heated': | ||
return 'too heated'; | ||
case 'resolved': | ||
return 'resolved'; | ||
case 'spam': | ||
return 'spam'; | ||
default: | ||
return 'resolved'; | ||
} | ||
})(); | ||
|
||
return await githubClient.issues.lock({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber, | ||
lock_reason: reason | ||
}); | ||
} | ||
|
||
export async function unlockIssue( | ||
githubClient: InstanceType<typeof GitHub>, | ||
issueNumber: number | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
): Promise<any> { | ||
return await githubClient.issues.unlock({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: issueNumber | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters