diff --git a/.github/workflows/close_stale.yml b/.github/workflows/close_stale.yml deleted file mode 100644 index ffd65477..00000000 --- a/.github/workflows/close_stale.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: "Close stale issues" -on: - push: {} - schedule: - - cron: 0 * * * * - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: bbq-beets/stale-bot@master - with: - stale_age_days: 60 - wait_after_stale_days: 7 - max_operations_per_run: 30 - env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/README.md b/README.md index 1347b321..67c4ba3f 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,14 @@ Basic: ``` name: "Close stale issues" on: - push: {} schedule: - - cron: 0 * * * * + - cron: "0 * * * *" jobs: stale: runs-on: ubuntu-latest steps: - - uses: bbq-beets/stale-bot@master + - uses: actions/stale@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'Message to comment on stale issues. If none provided, will not mark issues stale' @@ -29,15 +28,14 @@ Configure stale timeouts: ``` name: "Close stale issues" on: - push: {} schedule: - - cron: 0 * * * * + - cron: "0 * * * *" jobs: stale: runs-on: ubuntu-latest steps: - - uses: bbq-beets/stale-bot@master + - uses: actions/stale@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days' @@ -49,15 +47,14 @@ Configure labels: ``` name: "Close stale issues" on: - push: {} schedule: - - cron: 0 * * * * + - cron: "0 * * * *" jobs: stale: runs-on: ubuntu-latest steps: - - uses: bbq-beets/stale-bot@master + - uses: actions/stale@v1 with: repo-token: ${{ secrets.GITHUB_TOKEN }} stale-issue-message: 'Stale issue message' diff --git a/docs/contributors.md b/docs/contributors.md index fece2ea2..e6b5f5aa 100644 --- a/docs/contributors.md +++ b/docs/contributors.md @@ -2,21 +2,6 @@ ### Checkin -- Do checkin source (src) -- Do checkin build output (lib) -- Do checkin runtime node_modules -- Do not checkin devDependency node_modules (husky can help see below) - -### devDependencies - -In order to handle correctly checking in node_modules without devDependencies, we run [Husky](https://github.com/typicode/husky) before each commit. -This step ensures that formatting and checkin rules are followed and that devDependencies are excluded. To make sure Husky runs correctly, please use the following workflow: - -``` -npm install # installs all devDependencies including Husky -git add abc.ext # Add the files you've changed. This should include files in src, lib, and node_modules (see above) -git commit -m "Informative commit message" # Commit. This will run Husky -``` - -During the commit step, Husky will take care of formatting all files with [Prettier](https://github.com/prettier/prettier) as well as pruning out devDependencies using `npm prune --production`. -It will also make sure these changes are appropriately included in your commit (no further work is needed) \ No newline at end of file +- Do check in source (src) +- Do not check in build output (lib) +- Do not check in node_modules diff --git a/lib/main.js b/lib/main.js index a4c7ca94..b566e99f 100644 --- a/lib/main.js +++ b/lib/main.js @@ -47,6 +47,10 @@ function processIssues(client, args, operationsLeft, page = 1) { core.debug(`found issue: ${issue.title} last updated ${issue.updated_at}`); let isPr = !!issue.pull_request; let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage; + if (!staleMessage) { + core.debug(`skipping ${isPr ? "pr" : "issue"} due to empty message`); + continue; + } let staleLabel = isPr ? args.stalePrLabel : args.staleIssueLabel; if (isLabeledStale(issue, staleLabel)) { if (wasLastUpdatedBefore(issue, args.daysBeforeClose)) { @@ -68,12 +72,12 @@ function processIssues(client, args, operationsLeft, page = 1) { }); } function isLabeledStale(issue, label) { - return issue.labels.filter(i => i.name === label).length > 0; + const labelComparer = l => label.localeCompare(l.name, undefined, { sensitivity: 'accent' }); + return issue.labels.filter(labelComparer).length > 0; } function wasLastUpdatedBefore(issue, num_days) { const daysInMillis = 1000 * 60 * 60 * num_days; const millisSinceLastUpdated = new Date().getTime() - new Date(issue.updated_at).getTime(); - core.debug(`${daysInMillis}, ${millisSinceLastUpdated}`); return millisSinceLastUpdated >= daysInMillis; } function markStale(client, issue, staleMessage, staleLabel) { @@ -110,7 +114,7 @@ function getAndValidateArgs() { const args = { repoToken: core.getInput('repo-token', { required: true }), staleIssueMessage: core.getInput('stale-issue-message'), - stalePrMessage: core.getInput('stale-pr-message', { required: true }), + stalePrMessage: core.getInput('stale-pr-message'), daysBeforeStale: parseInt(core.getInput('days-before-stale', { required: true })), daysBeforeClose: parseInt(core.getInput('days-before-close', { required: true })), staleIssueLabel: core.getInput('stale-issue-label', { required: true }), diff --git a/package-lock.json b/package-lock.json index 0951e3e6..65c6d931 100644 --- a/package-lock.json +++ b/package-lock.json @@ -628,9 +628,9 @@ "dev": true }, "@types/node": { - "version": "12.6.9", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.6.9.tgz", - "integrity": "sha512-+YB9FtyxXGyD54p8rXwWaN1EWEyar5L58GlGWgtH2I9rGmLGBQcw63+0jw+ujqVavNuO47S1ByAjm9zdHMnskw==", + "version": "12.7.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.7.0.tgz", + "integrity": "sha512-vqcj1MVm2Sla4PpMfYKh1MyDN4D2f/mPIZD7RdAGqEsbE+JxfeqQHHVbRDQ0Nqn8i73gJa1HQ1Pu3+nH4Q0Yiw==", "dev": true }, "@types/normalize-package-data": { diff --git a/src/main.ts b/src/main.ts index 6c4d799b..3a5dfc4e 100644 --- a/src/main.ts +++ b/src/main.ts @@ -48,7 +48,13 @@ async function processIssues( for (var issue of issues.data.values()) { core.debug(`found issue: ${issue.title} last updated ${issue.updated_at}`); let isPr = !!issue.pull_request; + let staleMessage = isPr ? args.stalePrMessage : args.staleIssueMessage; + if (!staleMessage) { + core.debug(`skipping ${isPr ? "pr" : "issue"} due to empty message`); + continue; + } + let staleLabel = isPr ? args.stalePrLabel : args.staleIssueLabel; if (isLabeledStale(issue, staleLabel)) { @@ -80,7 +86,9 @@ function isLabeledStale( issue: Octokit.IssuesListForRepoResponseItem, label: string ): boolean { - return issue.labels.filter(i => i.name === label).length > 0; + const labelComparer = l => + label.localeCompare(l.name, undefined, {sensitivity: 'accent'}); + return issue.labels.filter(labelComparer).length > 0; } function wasLastUpdatedBefore( @@ -90,7 +98,6 @@ function wasLastUpdatedBefore( const daysInMillis = 1000 * 60 * 60 * num_days; const millisSinceLastUpdated = new Date().getTime() - new Date(issue.updated_at).getTime(); - core.debug(`${daysInMillis}, ${millisSinceLastUpdated}`); return millisSinceLastUpdated >= daysInMillis; } @@ -139,7 +146,7 @@ function getAndValidateArgs(): Args { const args = { repoToken: core.getInput('repo-token', {required: true}), staleIssueMessage: core.getInput('stale-issue-message'), - stalePrMessage: core.getInput('stale-pr-message', {required: true}), + stalePrMessage: core.getInput('stale-pr-message'), daysBeforeStale: parseInt( core.getInput('days-before-stale', {required: true}) ),