Skip to content

Commit f8d8eef

Browse files
authored
Merge pull request #291 from bcbrookman/feature/skip-empty-reports-option
feat: make skipping empty report creation configurable
2 parents d3d9303 + 303af19 commit f8d8eef

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ This action can be configured to authenticate with GitHub App Installation or Pe
6969
| `EXEMPT_TOPICS` | false | | Comma separated list of topics to exempt from being flagged as stale |
7070
| `ORGANIZATION` | false | | The organization to scan for stale repositories. If no organization is provided, this tool will search through repositories owned by the GH_TOKEN owner |
7171
| `ADDITIONAL_METRICS` | false | | Configure additional metrics like days since last release or days since last pull request. This allows for more detailed reporting on repository activity. To include both metrics, set `ADDITIONAL_METRICS: "release,pr"` |
72+
| `SKIP_EMPTY_REPORTS` | false | `true` | Skips report creation when no stale repositories are identified. Setting this input to `false` means reports are always created, even when they contain no results. |
7273

7374
### Example workflow
7475

stale_repos.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ def main(): # pragma: no cover
4141
gh_app_private_key = os.getenv("GH_APP_PRIVATE_KEY").encode("utf8")
4242
ghe = os.getenv("GH_ENTERPRISE_URL")
4343
gh_app_enterprise_only = os.getenv("GITHUB_APP_ENTERPRISE_ONLY")
44+
skip_empty_reports = (
45+
False if os.getenv("SKIP_EMPTY_REPORTS").lower() == "false" else True
46+
)
4447

4548
# Auth to GitHub.com or GHE
4649
github_connection = auth.auth_to_github(
@@ -73,11 +76,11 @@ def main(): # pragma: no cover
7376
github_connection, inactive_days_threshold, organization, additional_metrics
7477
)
7578

76-
if inactive_repos:
79+
if inactive_repos or not skip_empty_reports:
7780
output_to_json(inactive_repos)
7881
write_to_markdown(inactive_repos, inactive_days_threshold, additional_metrics)
7982
else:
80-
print("No stale repos found")
83+
print("Reporting skipped; no stale repos found.")
8184

8285

8386
def is_repo_exempt(repo, exempt_repos, exempt_topics):

0 commit comments

Comments
 (0)