Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Find stale repositories in a GitHub organization.

License

NotificationsYou must be signed in to change notification settings

github/stale-repos

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Lint Code BaseCodeQLDocker Image CIPython CIOpenSSF Scorecard

(Used by thegithub organization!)

This project identifies and reports repositories with no activity for configurable amount of time, in order to surface inactive repos to be considered for archival.The current approach assumes that the repos that you want to evaluate are available in a single GitHub organization.For the purpose of this action, a repository is considered inactive if it has not had apush in a configurable amount of days (can also be configured to determine activity based on default branch. SeeACTIVITY_METHOD for more details.).

This action was developed by GitHub so that we can keep our open source projects well maintained, and it was made open source in the hopes that it would help you too!We are actively using and are archiving things in batches since there are many repositories on our report.To find out more about how GitHub manages its open source, check out thegithub-ospo repository.

If you are looking to identify stale pull requests and issues, check outactions/stale

Support

If you need support using this project or have questions about it, pleaseopen up an issue in this repository.Requests made directly to GitHub staff or support team will be redirected here to open an issue.GitHub SLA's and support/services contracts do not apply to this repository.

OSPO GitHub Actions as a Whole

All feedback regarding our GitHub Actions, as a whole, should be communicated throughissues on our github-ospo repository.

Use as a GitHub Action

  1. Create a repository to host this GitHub Action or select an existing repository.
  2. Create the env values from the sample workflow below (GH_TOKEN,ORGANIZATION,EXEMPT_TOPICS) with your information as plain text or repository secrets. More info oncreating secrets.Note: Your GitHub token will need to have read access to all the repositories in the organization that you want evaluated
  3. Copy the below example workflow to your repository and put it in the.github/workflows/ directory with the file extension.yml (ie..github/workflows/stale_repos.yml)

Configuration

Below are the allowed configuration options:

Authentication

This action can be configured to authenticate with GitHub App Installation or Personal Access Token (PAT). If all configuration options are provided, the GitHub App Installation configuration has precedence. You can choose one of the following methods to authenticate:

GitHub App Installation
fieldrequireddefaultdescription
GH_APP_IDTrue""GitHub Application ID. Seedocumentation for more details.
GH_APP_INSTALLATION_IDTrue""GitHub Application Installation ID. Seedocumentation for more details.
GH_APP_PRIVATE_KEYTrue""GitHub Application Private Key. Seedocumentation for more details.
GITHUB_APP_ENTERPRISE_ONLYFalsefalseSet this input totrue if your app is created in GHE and communicates with GHE.
Personal Access Token (PAT)
fieldrequireddefaultdescription
GH_TOKENTrue""The GitHub Token used to scan the repository. Must have read access to all repository you are interested in scanning.

Other Configuration Options

fieldrequireddefaultdescription
ACTIVITY_METHODfalse"pushed"How to get the last active date of the repository. Defaults topushed, which is the last time any branch had a push. Can also be set todefault_branch_updated to instead measure from the latest commit on the default branch (good for filtering out dependabot )
GH_ENTERPRISE_URLfalse""URL of GitHub Enterprise instance to use for auth instead of github.com
INACTIVE_DAYStrueThe number of days used to determine if repository is stale, based onpush events
EXEMPT_REPOSfalseComma separated list of repositories to exempt from being flagged as stale. Supports Unix shell-style wildcards. ie.EXEMPT_REPOS = "stale-repos,test-repo,conf-*"
EXEMPT_TOPICSfalseComma separated list of topics to exempt from being flagged as stale
ORGANIZATIONfalseThe organization to scan for stale repositories. If no organization is provided, this tool will search through repositories owned by the GH_TOKEN owner
ADDITIONAL_METRICSfalseConfigure 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, setADDITIONAL_METRICS: "release,pr"
SKIP_EMPTY_REPORTSfalsetrueSkips report creation when no stale repositories are identified. Setting this input tofalse means reports are always created, even when they contain no results.
WORKFLOW_SUMMARY_ENABLEDfalsefalseWhen set totrue, automatically adds the stale repository report to the GitHub Actions workflow summary. This eliminates the need to manually add a step to display the Markdown content in the workflow summary.

Example workflow

name:stale repo identifieron:workflow_dispatch:schedule:    -cron:"3 2 1 * *"permissions:contents:readjobs:build:name:stale repo identifierruns-on:ubuntu-latestpermissions:contents:readissues:writesteps:      -uses:actions/checkout@v4      -name:Run stale_repos tooluses:github/stale-repos@v6env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:${{ secrets.ORGANIZATION }}EXEMPT_TOPICS:"keep,template"INACTIVE_DAYS:365ACTIVITY_METHOD:"pushed"ADDITIONAL_METRICS:"release,pr"# This next step updates an existing issue. If you want a new issue every time, remove this step and remove the `issue-number: ${{ env.issue_number }}` line below.      -name:Check for the stale report issuerun:|          ISSUE_NUMBER=$(gh search issues "Stale-repository-report" --match title --json number --jq ".[0].number")          echo "issue_number=$ISSUE_NUMBER" >> "$GITHUB_ENV"env:GH_TOKEN:${{ secrets.GITHUB_TOKEN }}      -name:Create issueuses:peter-evans/create-issue-from-file@v5with:issue-number:${{ env.issue_number }}title:Stale-repository-reportcontent-filepath:./stale_repos.mdassignees:<YOUR_GITHUB_HANDLE_HERE>token:${{ secrets.GITHUB_TOKEN }}

Using Workflow Summary

You can automatically include the stale repository report in your GitHub Actions workflow summary by settingWORKFLOW_SUMMARY_ENABLED: true. This eliminates the need for additional steps to display the results.

name:stale repo identifieron:workflow_dispatch:schedule:    -cron:"3 2 1 * *"permissions:contents:readjobs:build:name:stale repo identifierruns-on:ubuntu-lateststeps:      -name:Run stale_repos tooluses:github/stale-repos@v6env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:${{ secrets.ORGANIZATION }}EXEMPT_TOPICS:"keep,template"INACTIVE_DAYS:365ADDITIONAL_METRICS:"release,pr"WORKFLOW_SUMMARY_ENABLED:true

WhenWORKFLOW_SUMMARY_ENABLED is set totrue, the stale repository report will be automatically added to the GitHub Actions workflow summary, making it easy to see the results directly in the workflow run page.

Example stale_repos.md output

#Inactive RepositoriesThe following repos have not had a push event for more than 3 days:| Repository URL| Days Inactive| Last Push Date| Visibility| Days Since Last Release| Days Since Last PR|| ---------------------------------| ------------:| -------------:| ---------:| ----------------------:| -----------------:||https://github.com/github/.github|             5|      2020-1-30|    private|                      10|                  7|

Using JSON instead of Markdown

The action outputs inactive repos in JSON format for further actions as seen below or use the JSON contents from the file:stale_repos.json.

Example usage:

name:stale repo identifieron:workflow_dispatch:schedule:    -cron:"3 2 1 * *"permissions:contents:readjobs:build:name:stale repo identifierruns-on:ubuntu-lateststeps:      -name:Run stale_repos toolid:stale-reposuses:github/stale-repos@v3env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:${{ secrets.ORGANIZATION }}EXEMPT_TOPICS:"keep,template"INACTIVE_DAYS:365ADDITIONAL_METRICS:"release,pr"      -name:Print output of stale_repos toolrun:echo "${{ steps.stale-repos.outputs.inactiveRepos }}"      -uses:actions/github-script@v6with:script:|            const repos = ${{ steps.stale-repos.outputs.inactiveRepos }}            for (const repo of repos) {              console.log(repo);              const issue = await github.rest.issues.create({                owner: <ORG_OWNER>,                repo: <REPOSITORY>,                title: 'Stale repo' + repo.url,                body: 'This repo is stale. Please contact the owner to make it active again.',              });              console.log(issue);            }github-token:${{ secrets.GH_TOKEN }}

Running against multiple organizations?

You can utilize the GitHub Actions Matrix Strategy as shown below to run against multiple organizations. Note that this workflow example uses a manual trigger instead of a cron based trigger. Either works, this is just another option to consider.

on:  -workflow_dispatchname:Run the reportpermissions:contents:readjobs:report:name:run reportruns-on:ubuntu-lateststrategy:matrix:org:[org1, org2]steps:      -name:"run stale-repos"uses:github/stale-repos@v3env:GH_TOKEN:${{ secrets.GH_TOKEN }}ORGANIZATION:${{ matrix.org }}INACTIVE_DAYS:365ADDITIONAL_METRICS:"release,pr"

Authenticating with a GitHub App and Installation

You can authenticate as a GitHub App Installation by providing additional environment variables. IfGH_TOKEN is set alongside these GitHub App Installation variables, theGH_TOKEN will be ignored and not used.

on:  -workflow_dispatchname:Run the reportpermissions:contents:readjobs:build:name:stale repo identifierruns-on:ubuntu-lateststeps:      -uses:actions/checkout@v4      -name:Run stale_repos tooluses:github/stale-repos@v6env:GH_APP_ID:${{ secrets.GH_APP_ID }}GH_APP_INSTALLATION_ID:${{ secrets.GH_APP_INSTALLATION_ID }}GH_APP_PRIVATE_KEY:${{ secrets.GH_APP_PRIVATE_KEY }}#GITHUB_APP_ENTERPRISE_ONLY: true --> Set this if the gh app was created in GHE and the endpoint is also a GHE instanceORGANIZATION:${{ secrets.ORGANIZATION }}EXEMPT_TOPICS:"keep,template"INACTIVE_DAYS:365ACTIVITY_METHOD:"pushed"ADDITIONAL_METRICS:"release,pr"

Local usage without Docker

  1. Have Python v3.11 or greater installed
  2. Copy.env-example to.env
  3. Fill out the.env file with atoken from a user that has access to the organization to scan (listed below). Tokens should have admin:org or read:org access.
  4. Fill out the.env file with the desiredinactive_days value. This should be a whole positive number representing the amount of inactivity that you want for flagging stale repos.
  5. (Optional) Fill out the.env file with therepository topicsexempt_topics that you want to filter out from the stale repos report. This should be a comma separated list of topics.
  6. (Optional) Fill out the.env file with the exactorganization that you want to search in
  7. (Optional) Fill out the.env file with the exactURL of the GitHub Enterprise that you want to search in. Keep empty if you want to search in the publicgithub.com.
  8. pip install -r requirements.txt
  9. Runpython3 ./stale_repos.py, which will output a list of repositories and the length of their inactivity

Local testing without Docker

  1. Have Python v3.11 or greater installed
  2. pip install -r requirements.txt -r requirements-test.txt
  3. make lint
  4. make test

License

MIT

More OSPO Tools

Looking for more resources for your open source program office (OSPO)? Check out thegithub-ospo repository for a variety of tools designed to support your needs.


[8]ページ先頭

©2009-2025 Movatter.jp