Stale Repos Action
(Used by the github
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.
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 the github-ospo repository.
If you are looking to identify stale pull requests and issues, check out actions/stale
Support
If you need support using this project or have questions about it, please open 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.
Use as a GitHub Action
- Create a repository to host this GitHub Action or select an existing repository.
- Create the env values from the sample workflow below (GH_TOKEN, ORGANIZATION) with your information as repository secrets. More info on creating secrets can be found here. Note: Your GitHub token will need to have read/write access to all the repositories in the organization that you want evaluated
- 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:
field | required | default | description |
---|---|---|---|
GH_TOKEN |
true | The GitHub Token used to scan repositories. Must have read and write access to all repositories | |
ORGANIZATION |
true | The organization to scan for stale repositories | |
INACTIVE_DAYS |
true | The number of days used to determine if repository is stale | |
GH_ENTERPRISE_URL |
false | "" |
URL of GitHub Enterprise instance to use for auth instead of github.com |
Example workflow
name: stale repo identifier
on:
workflow_dispatch:
schedule:
- cron: '3 2 1 * *'
jobs:
build:
name: stale repo identifier
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run stale_repos tool
uses: docker://ghcr.io/github/stale_repos:v1
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
ORGANIZATION: ${{ secrets.ORGANIZATION }}
INACTIVE_DAYS: 365
- name: Create issue
uses: peter-evans/create-issue-from-file@v4
with:
title: Stale repository report
content-filepath: ./stale_repos.md
assignees: <YOUR_GITHUB_HANDLE_HERE>
Example stale_repos.md output
# Inactive Repositories
| Repository URL | Days Inactive |
| --- | ---: |
| https://github.com/github/.github | 5 |
Local usage without Docker
- Copy
.env-example
to.env
- Fill out the
.env
file with a token from a user that has access to the organization to scan (listed below). Tokens should have admin:org or read:org access. - Fill out the
.env
file with the desired inactive_days value. This should be a whole positive number representing the amount of inactivity that you want for flagging stale repos. - Fill out the
.env
file with the exact organization that you want to search in - (Optional) Fill out the
.env
file with the exact URL of the GitHub Enterprise that you want to search in. Keep empty if you want to search in the publicgithub.com
. pip install -r requirements.txt
- Run
python3 ./stale_repos.py
, which will output a list of repositories and the length of their inactivity