Skip to content

Commit

Permalink
Add repository input
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart Izon committed Jan 4, 2024
1 parent eb40ad8 commit 3d7e8ee
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ jobs:
uses: RelationalAI/abandoned@main
with:
days: 7
repository: facebook/react
token: ${{ github.token }}
- run: "echo PRs: ${{ steps.abandoned.outputs.pulls }}"
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ This action finds old, abandoned PRs for a given repository.
```
- uses: RelationalAI/abandoned
with:
# Repository name with owner.
# Default: ${{ github.repository }}
repository: ''
# Number of days before PR should be considered abandoned
days: 7
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ name: 'Abandoned'
description: 'Finds old, abandoned PRs in a given repository'

inputs:
repository:
description: Repository name with owner.
default: ${{ github.repository }}
days:
description: 'Number of days before PR should be considered abandoned'
required: false
Expand Down
15 changes: 14 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41343,13 +41343,26 @@ const { ZonedDateTime, Duration } = __nccwpck_require__(2709);
async function run() {
try {
const token = core.getInput("token");
const repository = core.getInput("repository");
const numDays = parseInt(core.getInput("days"));
const octokit = github.getOctokit(token);
const now = ZonedDateTime.now();

const splitRepository = repository.split("/");
if (
splitRepository.length !== 2 ||
!splitRepository[0] ||
!splitRepository[1]
) {
throw new Error(
`Invalid repository '${qualifiedRepository}'. Expected format {owner}/{repo}.`
);
}
const repo = { owner: splitRepository[0], repo: splitRepository[1] };

const pulls = await octokit.paginate(
octokit.rest.pulls.list,
{ ...github.context.repo, state: "open" },
{ ...repo, state: "open" },
(response) =>
response.data
.filter(
Expand Down
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,26 @@ const { ZonedDateTime, Duration } = require("@js-joda/core");
async function run() {
try {
const token = core.getInput("token");
const repository = core.getInput("repository");
const numDays = parseInt(core.getInput("days"));
const octokit = github.getOctokit(token);
const now = ZonedDateTime.now();

const splitRepository = repository.split("/");
if (
splitRepository.length !== 2 ||
!splitRepository[0] ||
!splitRepository[1]
) {
throw new Error(
`Invalid repository '${qualifiedRepository}'. Expected format {owner}/{repo}.`
);
}
const repo = { owner: splitRepository[0], repo: splitRepository[1] };

const pulls = await octokit.paginate(
octokit.rest.pulls.list,
{ ...github.context.repo, state: "open" },
{ ...repo, state: "open" },
(response) =>
response.data
.filter(
Expand Down

0 comments on commit 3d7e8ee

Please sign in to comment.