add ability to pass a different repo-owner and repo-name
This commit is contained in:
parent
184e7afe93
commit
4aaf80b0a1
16
README.md
16
README.md
|
@ -45,6 +45,8 @@ Every argument is optional.
|
||||||
| Input | Description | Default |
|
| Input | Description | Default |
|
||||||
| ------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------- |
|
| ------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------- |
|
||||||
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` |
|
| [repo-token](#repo-token) | PAT for GitHub API authentication | `${{ github.token }}` |
|
||||||
|
| [repo-owner](#repo-owner) | Owner of the repository | `${{ github.repository_owner }}` |
|
||||||
|
| [repo-name](#repo-name) | Name of the repository | `${{ github.event.repository.name }}` |
|
||||||
| [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` |
|
| [days-before-stale](#days-before-stale) | Idle number of days before marking issues/PRs stale | `60` |
|
||||||
| [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | |
|
| [days-before-issue-stale](#days-before-issue-stale) | Override [days-before-stale](#days-before-stale) for issues only | |
|
||||||
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
|
| [days-before-pr-stale](#days-before-pr-stale) | Override [days-before-stale](#days-before-stale) for PRs only | |
|
||||||
|
@ -109,11 +111,23 @@ Every argument is optional.
|
||||||
|
|
||||||
#### repo-token
|
#### repo-token
|
||||||
|
|
||||||
Personal Access Token (PAT) that allows the stale workflow to authenticate and perform API calls to GitHub.
|
Personal Access Token (PAT) that allows the stale workflow to authenticate and perform API calls to GitHub in the specified repository.
|
||||||
Under the hood, it uses the [@actions/github](https://www.npmjs.com/package/@actions/github) package.
|
Under the hood, it uses the [@actions/github](https://www.npmjs.com/package/@actions/github) package.
|
||||||
|
|
||||||
Default value: `${{ github.token }}`
|
Default value: `${{ github.token }}`
|
||||||
|
|
||||||
|
#### repo-owner
|
||||||
|
|
||||||
|
The owner / organization of the repository that you wish to run the stale workflow on.
|
||||||
|
|
||||||
|
Default value: `${{ github.repository_owner }}`
|
||||||
|
|
||||||
|
#### repo-name
|
||||||
|
|
||||||
|
The name of the repository that you wish to run the stale workflow on.
|
||||||
|
|
||||||
|
Default value: `${{ github.event.repository.name }}`
|
||||||
|
|
||||||
#### days-before-stale
|
#### days-before-stale
|
||||||
|
|
||||||
The idle number of days before marking the issues or the pull requests as stale (by adding a label).
|
The idle number of days before marking the issues or the pull requests as stale (by adding a label).
|
||||||
|
|
|
@ -4,6 +4,8 @@ import {IIssuesProcessorOptions} from '../../src/interfaces/issues-processor-opt
|
||||||
// Mirrors the defaults defined in action.yml
|
// Mirrors the defaults defined in action.yml
|
||||||
export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
export const DefaultProcessorOptions: IIssuesProcessorOptions = Object.freeze({
|
||||||
repoToken: 'none',
|
repoToken: 'none',
|
||||||
|
repoOwner: '',
|
||||||
|
repoName: '',
|
||||||
staleIssueMessage: 'This issue is stale',
|
staleIssueMessage: 'This issue is stale',
|
||||||
stalePrMessage: 'This PR is stale',
|
stalePrMessage: 'This PR is stale',
|
||||||
closeIssueMessage: 'This issue is being closed',
|
closeIssueMessage: 'This issue is being closed',
|
||||||
|
|
|
@ -6,6 +6,12 @@ inputs:
|
||||||
description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`.'
|
description: 'Token for the repository. Can be passed in using `{{ secrets.GITHUB_TOKEN }}`.'
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.token }}
|
default: ${{ github.token }}
|
||||||
|
repo-owner:
|
||||||
|
description: 'Name of the organization / owner of the repository that you want to manage'
|
||||||
|
required: false
|
||||||
|
repo-name:
|
||||||
|
description: 'Name of the repository that you want to apply stale bot'
|
||||||
|
required: false
|
||||||
stale-issue-message:
|
stale-issue-message:
|
||||||
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues stale.'
|
description: 'The message to post on the issue when tagging it. If none provided, will not mark issues stale.'
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -659,8 +659,8 @@ class IssuesProcessor {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCommentsCount();
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsCommentsCount();
|
||||||
const comments = yield this.client.rest.issues.listComments({
|
const comments = yield this.client.rest.issues.listComments({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
since: sinceDate
|
since: sinceDate
|
||||||
});
|
});
|
||||||
|
@ -679,8 +679,8 @@ class IssuesProcessor {
|
||||||
try {
|
try {
|
||||||
this.operations.consumeOperation();
|
this.operations.consumeOperation();
|
||||||
const issueResult = yield this.client.rest.issues.listForRepo({
|
const issueResult = yield this.client.rest.issues.listForRepo({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
state: 'open',
|
state: 'open',
|
||||||
per_page: 100,
|
per_page: 100,
|
||||||
direction: this.options.ascending ? 'asc' : 'desc',
|
direction: this.options.ascending ? 'asc' : 'desc',
|
||||||
|
@ -704,8 +704,8 @@ class IssuesProcessor {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount();
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedItemsEventsCount();
|
||||||
const options = this.client.rest.issues.listEvents.endpoint.merge({
|
const options = this.client.rest.issues.listEvents.endpoint.merge({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
per_page: 100,
|
per_page: 100,
|
||||||
issue_number: issue.number
|
issue_number: issue.number
|
||||||
});
|
});
|
||||||
|
@ -728,8 +728,8 @@ class IssuesProcessor {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount();
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementFetchedPullRequestsCount();
|
||||||
const pullRequest = yield this.client.rest.pulls.get({
|
const pullRequest = yield this.client.rest.pulls.get({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
pull_number: issue.number
|
pull_number: issue.number
|
||||||
});
|
});
|
||||||
return pullRequest.data;
|
return pullRequest.data;
|
||||||
|
@ -848,8 +848,8 @@ class IssuesProcessor {
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue);
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsComment(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.createComment({
|
yield this.client.rest.issues.createComment({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
body: staleMessage
|
body: staleMessage
|
||||||
});
|
});
|
||||||
|
@ -865,8 +865,8 @@ class IssuesProcessor {
|
||||||
(_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue);
|
(_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementStaleItemsCount(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.addLabels({
|
yield this.client.rest.issues.addLabels({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: [staleLabel]
|
labels: [staleLabel]
|
||||||
});
|
});
|
||||||
|
@ -891,8 +891,8 @@ class IssuesProcessor {
|
||||||
this.addedCloseCommentIssues.push(issue);
|
this.addedCloseCommentIssues.push(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.createComment({
|
yield this.client.rest.issues.createComment({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
body: closeMessage
|
body: closeMessage
|
||||||
});
|
});
|
||||||
|
@ -908,8 +908,8 @@ class IssuesProcessor {
|
||||||
(_b = this.statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue);
|
(_b = this.statistics) === null || _b === void 0 ? void 0 : _b.incrementAddedItemsLabel(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.addLabels({
|
yield this.client.rest.issues.addLabels({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: [closeLabel]
|
labels: [closeLabel]
|
||||||
});
|
});
|
||||||
|
@ -924,8 +924,8 @@ class IssuesProcessor {
|
||||||
(_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue);
|
(_c = this.statistics) === null || _c === void 0 ? void 0 : _c.incrementClosedItemsCount(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.update({
|
yield this.client.rest.issues.update({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
state: 'closed',
|
state: 'closed',
|
||||||
state_reason: this.options.closeIssueReason || undefined
|
state_reason: this.options.closeIssueReason || undefined
|
||||||
|
@ -955,15 +955,15 @@ class IssuesProcessor {
|
||||||
const branch = pullRequest.head.ref;
|
const branch = pullRequest.head.ref;
|
||||||
if (pullRequest.head.repo === null ||
|
if (pullRequest.head.repo === null ||
|
||||||
pullRequest.head.repo.full_name ===
|
pullRequest.head.repo.full_name ===
|
||||||
`${github_1.context.repo.owner}/${github_1.context.repo.repo}`) {
|
`${this.options.repoOwner}/${this.options.repoName}`) {
|
||||||
issueLogger.info(`Deleting the branch "${logger_service_1.LoggerService.cyan(branch)}" from closed $$type`);
|
issueLogger.info(`Deleting the branch "${logger_service_1.LoggerService.cyan(branch)}" from closed $$type`);
|
||||||
try {
|
try {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedBranchesCount();
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedBranchesCount();
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.git.deleteRef({
|
yield this.client.rest.git.deleteRef({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
ref: `heads/${branch}`
|
ref: `heads/${branch}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -989,8 +989,8 @@ class IssuesProcessor {
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedItemsLabelsCount(issue);
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementDeletedItemsLabelsCount(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.removeLabel({
|
yield this.client.rest.issues.removeLabel({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
name: label
|
name: label
|
||||||
});
|
});
|
||||||
|
@ -1089,8 +1089,8 @@ class IssuesProcessor {
|
||||||
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue);
|
(_a = this.statistics) === null || _a === void 0 ? void 0 : _a.incrementAddedItemsLabel(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
yield this.client.rest.issues.addLabels({
|
yield this.client.rest.issues.addLabels({
|
||||||
owner: github_1.context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: github_1.context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: labelsToAdd
|
labels: labelsToAdd
|
||||||
});
|
});
|
||||||
|
@ -2170,6 +2170,8 @@ exports.Option = void 0;
|
||||||
var Option;
|
var Option;
|
||||||
(function (Option) {
|
(function (Option) {
|
||||||
Option["RepoToken"] = "repo-token";
|
Option["RepoToken"] = "repo-token";
|
||||||
|
Option["RepoOwner"] = "repo-owner";
|
||||||
|
Option["RepoName"] = "repo-name";
|
||||||
Option["StaleIssueMessage"] = "stale-issue-message";
|
Option["StaleIssueMessage"] = "stale-issue-message";
|
||||||
Option["StalePrMessage"] = "stale-pr-message";
|
Option["StalePrMessage"] = "stale-pr-message";
|
||||||
Option["CloseIssueMessage"] = "close-issue-message";
|
Option["CloseIssueMessage"] = "close-issue-message";
|
||||||
|
@ -2477,6 +2479,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const github_1 = __nccwpck_require__(5438);
|
||||||
const issues_processor_1 = __nccwpck_require__(3292);
|
const issues_processor_1 = __nccwpck_require__(3292);
|
||||||
const is_valid_date_1 = __nccwpck_require__(891);
|
const is_valid_date_1 = __nccwpck_require__(891);
|
||||||
const state_service_1 = __nccwpck_require__(6330);
|
const state_service_1 = __nccwpck_require__(6330);
|
||||||
|
@ -2511,6 +2514,12 @@ function _run() {
|
||||||
function _getAndValidateArgs() {
|
function _getAndValidateArgs() {
|
||||||
const args = {
|
const args = {
|
||||||
repoToken: core.getInput('repo-token'),
|
repoToken: core.getInput('repo-token'),
|
||||||
|
repoOwner: core.getInput('repo-owner') === ''
|
||||||
|
? github_1.context.repo.owner
|
||||||
|
: core.getInput('repo-owner'),
|
||||||
|
repoName: core.getInput('repo-name') === ''
|
||||||
|
? github_1.context.repo.repo
|
||||||
|
: core.getInput('repo-name'),
|
||||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||||
stalePrMessage: core.getInput('stale-pr-message'),
|
stalePrMessage: core.getInput('stale-pr-message'),
|
||||||
closeIssueMessage: core.getInput('close-issue-message'),
|
closeIssueMessage: core.getInput('close-issue-message'),
|
||||||
|
|
|
@ -38,6 +38,8 @@ describe('Issue', (): void => {
|
||||||
removeIssueStaleWhenUpdated: undefined,
|
removeIssueStaleWhenUpdated: undefined,
|
||||||
removePrStaleWhenUpdated: undefined,
|
removePrStaleWhenUpdated: undefined,
|
||||||
repoToken: '',
|
repoToken: '',
|
||||||
|
repoOwner: '',
|
||||||
|
repoName: '',
|
||||||
staleIssueMessage: '',
|
staleIssueMessage: '',
|
||||||
stalePrMessage: '',
|
stalePrMessage: '',
|
||||||
startDate: undefined,
|
startDate: undefined,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import {context, getOctokit} from '@actions/github';
|
import {getOctokit} from '@actions/github';
|
||||||
import {GitHub} from '@actions/github/lib/utils';
|
import {GitHub} from '@actions/github/lib/utils';
|
||||||
import {Option} from '../enums/option';
|
import {Option} from '../enums/option';
|
||||||
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
import {getHumanizedDate} from '../functions/dates/get-humanized-date';
|
||||||
|
@ -548,8 +548,8 @@ export class IssuesProcessor {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
this.statistics?.incrementFetchedItemsCommentsCount();
|
this.statistics?.incrementFetchedItemsCommentsCount();
|
||||||
const comments = await this.client.rest.issues.listComments({
|
const comments = await this.client.rest.issues.listComments({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
since: sinceDate
|
since: sinceDate
|
||||||
});
|
});
|
||||||
|
@ -565,8 +565,8 @@ export class IssuesProcessor {
|
||||||
try {
|
try {
|
||||||
this.operations.consumeOperation();
|
this.operations.consumeOperation();
|
||||||
const issueResult = await this.client.rest.issues.listForRepo({
|
const issueResult = await this.client.rest.issues.listForRepo({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
state: 'open',
|
state: 'open',
|
||||||
per_page: 100,
|
per_page: 100,
|
||||||
direction: this.options.ascending ? 'asc' : 'desc',
|
direction: this.options.ascending ? 'asc' : 'desc',
|
||||||
|
@ -596,8 +596,8 @@ export class IssuesProcessor {
|
||||||
this._consumeIssueOperation(issue);
|
this._consumeIssueOperation(issue);
|
||||||
this.statistics?.incrementFetchedItemsEventsCount();
|
this.statistics?.incrementFetchedItemsEventsCount();
|
||||||
const options = this.client.rest.issues.listEvents.endpoint.merge({
|
const options = this.client.rest.issues.listEvents.endpoint.merge({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
per_page: 100,
|
per_page: 100,
|
||||||
issue_number: issue.number
|
issue_number: issue.number
|
||||||
});
|
});
|
||||||
|
@ -627,8 +627,8 @@ export class IssuesProcessor {
|
||||||
this.statistics?.incrementFetchedPullRequestsCount();
|
this.statistics?.incrementFetchedPullRequestsCount();
|
||||||
|
|
||||||
const pullRequest = await this.client.rest.pulls.get({
|
const pullRequest = await this.client.rest.pulls.get({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
pull_number: issue.number
|
pull_number: issue.number
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -847,8 +847,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.createComment({
|
await this.client.rest.issues.createComment({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
body: staleMessage
|
body: staleMessage
|
||||||
});
|
});
|
||||||
|
@ -865,8 +865,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.addLabels({
|
await this.client.rest.issues.addLabels({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: [staleLabel]
|
labels: [staleLabel]
|
||||||
});
|
});
|
||||||
|
@ -895,8 +895,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.createComment({
|
await this.client.rest.issues.createComment({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
body: closeMessage
|
body: closeMessage
|
||||||
});
|
});
|
||||||
|
@ -913,8 +913,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.addLabels({
|
await this.client.rest.issues.addLabels({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: [closeLabel]
|
labels: [closeLabel]
|
||||||
});
|
});
|
||||||
|
@ -930,8 +930,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.update({
|
await this.client.rest.issues.update({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
state: 'closed',
|
state: 'closed',
|
||||||
state_reason: this.options.closeIssueReason || undefined
|
state_reason: this.options.closeIssueReason || undefined
|
||||||
|
@ -967,7 +967,7 @@ export class IssuesProcessor {
|
||||||
if (
|
if (
|
||||||
pullRequest.head.repo === null ||
|
pullRequest.head.repo === null ||
|
||||||
pullRequest.head.repo.full_name ===
|
pullRequest.head.repo.full_name ===
|
||||||
`${context.repo.owner}/${context.repo.repo}`
|
`${this.options.repoOwner}/${this.options.repoName}`
|
||||||
) {
|
) {
|
||||||
issueLogger.info(
|
issueLogger.info(
|
||||||
`Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type`
|
`Deleting the branch "${LoggerService.cyan(branch)}" from closed $$type`
|
||||||
|
@ -979,8 +979,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.git.deleteRef({
|
await this.client.rest.git.deleteRef({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
ref: `heads/${branch}`
|
ref: `heads/${branch}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1023,8 +1023,8 @@ export class IssuesProcessor {
|
||||||
|
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.removeLabel({
|
await this.client.rest.issues.removeLabel({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
name: label
|
name: label
|
||||||
});
|
});
|
||||||
|
@ -1161,8 +1161,8 @@ export class IssuesProcessor {
|
||||||
this.statistics?.incrementAddedItemsLabel(issue);
|
this.statistics?.incrementAddedItemsLabel(issue);
|
||||||
if (!this.options.debugOnly) {
|
if (!this.options.debugOnly) {
|
||||||
await this.client.rest.issues.addLabels({
|
await this.client.rest.issues.addLabels({
|
||||||
owner: context.repo.owner,
|
owner: this.options.repoOwner,
|
||||||
repo: context.repo.repo,
|
repo: this.options.repoName,
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
labels: labelsToAdd
|
labels: labelsToAdd
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
export enum Option {
|
export enum Option {
|
||||||
RepoToken = 'repo-token',
|
RepoToken = 'repo-token',
|
||||||
|
RepoOwner = 'repo-owner',
|
||||||
|
RepoName = 'repo-name',
|
||||||
StaleIssueMessage = 'stale-issue-message',
|
StaleIssueMessage = 'stale-issue-message',
|
||||||
StalePrMessage = 'stale-pr-message',
|
StalePrMessage = 'stale-pr-message',
|
||||||
CloseIssueMessage = 'close-issue-message',
|
CloseIssueMessage = 'close-issue-message',
|
||||||
|
|
|
@ -2,6 +2,8 @@ import {IsoOrRfcDateString} from '../types/iso-or-rfc-date-string';
|
||||||
|
|
||||||
export interface IIssuesProcessorOptions {
|
export interface IIssuesProcessorOptions {
|
||||||
repoToken: string;
|
repoToken: string;
|
||||||
|
repoOwner: string;
|
||||||
|
repoName: string;
|
||||||
staleIssueMessage: string;
|
staleIssueMessage: string;
|
||||||
stalePrMessage: string;
|
stalePrMessage: string;
|
||||||
closeIssueMessage: string;
|
closeIssueMessage: string;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import {context} from '@actions/github';
|
||||||
import {IssuesProcessor} from './classes/issues-processor';
|
import {IssuesProcessor} from './classes/issues-processor';
|
||||||
import {isValidDate} from './functions/dates/is-valid-date';
|
import {isValidDate} from './functions/dates/is-valid-date';
|
||||||
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
import {IIssuesProcessorOptions} from './interfaces/issues-processor-options';
|
||||||
|
@ -57,6 +58,14 @@ async function _run(): Promise<void> {
|
||||||
function _getAndValidateArgs(): IIssuesProcessorOptions {
|
function _getAndValidateArgs(): IIssuesProcessorOptions {
|
||||||
const args: IIssuesProcessorOptions = {
|
const args: IIssuesProcessorOptions = {
|
||||||
repoToken: core.getInput('repo-token'),
|
repoToken: core.getInput('repo-token'),
|
||||||
|
repoOwner:
|
||||||
|
core.getInput('repo-owner') === ''
|
||||||
|
? context.repo.owner
|
||||||
|
: core.getInput('repo-owner'),
|
||||||
|
repoName:
|
||||||
|
core.getInput('repo-name') === ''
|
||||||
|
? context.repo.repo
|
||||||
|
: core.getInput('repo-name'),
|
||||||
staleIssueMessage: core.getInput('stale-issue-message'),
|
staleIssueMessage: core.getInput('stale-issue-message'),
|
||||||
stalePrMessage: core.getInput('stale-pr-message'),
|
stalePrMessage: core.getInput('stale-pr-message'),
|
||||||
closeIssueMessage: core.getInput('close-issue-message'),
|
closeIssueMessage: core.getInput('close-issue-message'),
|
||||||
|
|
Loading…
Reference in New Issue