Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antgrutta/update readme #10

Merged
merged 3 commits into from
Apr 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 16 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,21 @@
# Get Repository Statistics

GitHub CLI extensions are repositories that provide additional gh commands, and this GitHub CLI extension can help you find information about your repositories in your system.
GitHub CLI extensions are repositories that provide additional gh commands, and this GitHub CLI extension can help you find information about your repositories in your organizations.

## Prerequisites

- You need to have GitHub CLI installed by following this documentation: <https://github.com/cli/cli#installation>
- You need to have an operating system to run shell script
- You need to have an operating system to run shell scripts

You need to either export these environment variables

| Environment Variable name | Value |
| ------------------------- | ----- |
| GITHUB_TOKEN | GitHub Personal Access Token (PAT) with `admin:org`, `user:all`, and `repo:all` permissions
| ORG_NAME | Organization name to run script |
| GHE_URL | GitHub URL or GHES URL without HTTP or HTTPS |
| Environment Variable name | Value |
| ------------------------- | ------------------------------------------------------------------------------------------- |
| GITHUB_TOKEN | GitHub Personal Access Token (PAT) with `admin:org`, `user:all`, and `repo:all` permissions |
| ORG_NAME | Organization name to run script |
| GHE_URL | GitHub URL or GHES URL without HTTP or HTTPS |

You can export these environment variables with following commands:

```sh
export GITHUB_TOKEN=<Your GitHub PAT>
export ORG_NAME=<Your Org name>
export GHE_URL=<Your GHE URL>
```

You can also create an environment variable named `.env` in following format:

```sh
GITHUB_TOKEN=<Your GitHub PAT>
ORG_NAME=<Your Org name>
GHE_URL=<Your GHE URL>
```

Then, you can source with a following command:

```sh
source .env
```
Or the script will prompt you to put in the relevant information.

## How to run

Expand All @@ -47,18 +27,15 @@ Make sure you followed prerequisites and then follow this instruction.
gh extension install mona-actions/gh-repo-stats
```

### Input file
If you want to run this over multiple Orgs, you can pass an `input file` when starting the script
- `./get-repo-statistics.sh --input Org-file.csv`
- This will read in a list of orgs and run over the list
![Step 1](./screenshots/step1.png)

The input file needs to be in the following format:
### Step 2: Run gh repo-stats

```csv
trash,more-trash,OrgName1
trash,more-trash,OrgName2
trash,more-trash,OrgName3
trash,more-trash,OrgName4
```sh
gh repo-stats --org-name=<ORG_NAME> --ghe-url=<GHE_URL> --token=<GITHUB_TOKEN>
```

**NOTE:** The input file was originally pulled from a previous location and the objects in columns `1` and `2` are only placeholders in this context.
### Example Output

![Output 1](./screenshots/output1.png)
![Output 2](./screenshots/output2.png)
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes