mirror of
https://github.com/actions/stale.git
synced 2025-12-12 04:57:15 +00:00
Update to latest actions and octokit libraries (#124)
Upgrade to latest libraries but use "any" for the client until I figure out how to use the right type
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as github from '@actions/github';
|
||||
import {Octokit} from '@octokit/rest';
|
||||
|
||||
type OctoKitIssueList = Octokit.Response<Octokit.IssuesListForRepoResponse>;
|
||||
import {context, getOctokit} from '@actions/github';
|
||||
import {GetResponseTypeFromEndpointMethod} from '@octokit/types';
|
||||
|
||||
export interface Issue {
|
||||
title: string;
|
||||
@@ -58,7 +56,7 @@ export interface IssueProcessorOptions {
|
||||
* Handle processing of issues for staleness/closure.
|
||||
*/
|
||||
export class IssueProcessor {
|
||||
readonly client: github.GitHub;
|
||||
readonly client: any; // need to make this the correct type
|
||||
readonly options: IssueProcessorOptions;
|
||||
private operationsLeft = 0;
|
||||
|
||||
@@ -80,7 +78,7 @@ export class IssueProcessor {
|
||||
) {
|
||||
this.options = options;
|
||||
this.operationsLeft = options.operationsPerRun;
|
||||
this.client = new github.GitHub(options.repoToken);
|
||||
this.client = getOctokit(options.repoToken);
|
||||
|
||||
if (getIssues) {
|
||||
this.getIssues = getIssues;
|
||||
@@ -268,12 +266,11 @@ export class IssueProcessor {
|
||||
|
||||
const filteredComments = comments.filter(
|
||||
comment =>
|
||||
comment.user.type === 'User' &&
|
||||
comment.user.login !== github.context.actor
|
||||
comment.user.type === 'User' && comment.user.login !== context.actor
|
||||
);
|
||||
|
||||
core.info(
|
||||
`Comments not made by ${github.context.actor} or another bot: ${filteredComments.length}`
|
||||
`Comments not made by ${context.actor} or another bot: ${filteredComments.length}`
|
||||
);
|
||||
|
||||
// if there are any user comments returned
|
||||
@@ -288,8 +285,8 @@ export class IssueProcessor {
|
||||
// find any comments since date on the given issue
|
||||
try {
|
||||
const comments = await this.client.issues.listComments({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issueNumber,
|
||||
since: sinceDate
|
||||
});
|
||||
@@ -302,11 +299,15 @@ export class IssueProcessor {
|
||||
|
||||
// grab issues from github in baches of 100
|
||||
private async getIssues(page: number): Promise<Issue[]> {
|
||||
// generate type for response
|
||||
const endpoint = this.client.issues.listForRepo;
|
||||
type OctoKitIssueList = GetResponseTypeFromEndpointMethod<typeof endpoint>;
|
||||
|
||||
try {
|
||||
const issueResult: OctoKitIssueList = await this.client.issues.listForRepo(
|
||||
{
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: 'open',
|
||||
labels: this.options.onlyLabels,
|
||||
per_page: 100,
|
||||
@@ -346,8 +347,8 @@ export class IssueProcessor {
|
||||
if (!skipMessage) {
|
||||
try {
|
||||
await this.client.issues.createComment({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: staleMessage
|
||||
});
|
||||
@@ -358,8 +359,8 @@ export class IssueProcessor {
|
||||
|
||||
try {
|
||||
await this.client.issues.addLabels({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
labels: [staleLabel]
|
||||
});
|
||||
@@ -385,8 +386,8 @@ export class IssueProcessor {
|
||||
if (closeMessage) {
|
||||
try {
|
||||
await this.client.issues.createComment({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
body: closeMessage
|
||||
});
|
||||
@@ -397,8 +398,8 @@ export class IssueProcessor {
|
||||
|
||||
try {
|
||||
await this.client.issues.update({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
state: 'closed'
|
||||
});
|
||||
@@ -423,8 +424,8 @@ export class IssueProcessor {
|
||||
|
||||
try {
|
||||
await this.client.issues.removeLabel({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
issue_number: issue.number,
|
||||
name: encodeURIComponent(label) // A label can have a "?" in the name
|
||||
});
|
||||
@@ -444,8 +445,8 @@ export class IssueProcessor {
|
||||
this.operationsLeft -= 1;
|
||||
|
||||
const options = this.client.issues.listEvents.endpoint.merge({
|
||||
owner: github.context.repo.owner,
|
||||
repo: github.context.repo.repo,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
per_page: 100,
|
||||
issue_number: issue.number
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user