Skip to content

Commit

Permalink
Merge pull request #2 from github/use-action
Browse files Browse the repository at this point in the history
ci: create action to test that this thing works
  • Loading branch information
zkoppert committed May 23, 2023
2 parents 05d4478 + 3ffd148 commit 53e65ae
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag stale_repos:"$(date +%s)"
run: docker build . --file Dockerfile --platform linux/amd64 --tag stale_repos:"$(date +%s)"
31 changes: 31 additions & 0 deletions .github/workflows/use-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: stale repo identifier

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
schedule:
- cron: '3 2 1 * *'

permissions:
contents: read
issues: write
packages: read

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: github
INACTIVE_DAYS: 1
6 changes: 0 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,3 @@ RUN python3 -m pip install --no-cache-dir -r requirements.txt \

CMD ["/action/workspace/stale_repos.py"]
ENTRYPOINT ["python3", "-u"]

# To run ineractive debug on the docker container
# 1. Comment out the above CMD and ENTRYPOINT lines
# 2. Uncomment the ENTRYPOINT line below

#ENTRYPOINT ["bash"]
5 changes: 5 additions & 0 deletions stale_repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def main():
If GH_ENTERPRISE_URL is set, the script will authenticate to a GitHub Enterprise
instance instead of github.com.
"""
print("Starting stale repo search...")

# Load env variables from file
dotenv_path = join(dirname(__file__), ".env")
load_dotenv(dotenv_path)
Expand Down Expand Up @@ -54,14 +56,17 @@ def main():

# Iterate over repos in the org, acquire inactive days,
# and print out the repo url and days inactive if it's over the threshold (inactive_days)
inactive_repos = []
for repo in github_connection.repositories_by(organization):
last_push_str = repo.pushed_at # type: ignore
if last_push_str is None:
continue
last_push = parse(last_push_str)
days_inactive = (datetime.now() - last_push).days
if days_inactive > int(inactive_days_threshold):
inactive_repos.append((repo, days_inactive))
print(f"{repo.html_url}: {days_inactive} days inactive") # type: ignore
print(f"Found {len(inactive_repos)} stale repos in {organization}")


if __name__ == "__main__":
Expand Down

0 comments on commit 53e65ae

Please sign in to comment.