Skip to content

Commit d38c7bd

Browse files
committed
Update README
1 parent 18ba34a commit d38c7bd

File tree

2 files changed

+46
-35
lines changed

2 files changed

+46
-35
lines changed

README.md

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# gh add-files : A GitHub CLI Extension
22

33
The `gh add files` is a GitHub CLI Extension that allows you to add files to your GitHub repositories directly from the command line.
4-
`v1.x.x` of this tool exculsively accomodates `codeql.yml` files, that are committed to the `.github/workflows/codeql.yml` path of the repository.
54

6-
This tool streamlines the process of rolling out Code Scanning to your Organization when using centralised workflows.
5+
This tool currently streamlies the process of enabling advanced setup for Code Scanning to your repositories.
76

87
### Prerequisites
98

@@ -20,55 +19,67 @@ gh extension install add-files
2019

2120
## Features
2221

23-
### Code Scanning Enable All
22+
### Code Scanning
23+
24+
To enable advanced setup for code scanning, you can use the following command with the following usage:
2425

25-
You can add a code scanning workflow file to every repository in the organisation by running the following command:
2626
```bash
27-
gh add-files code-scanning-enable-all -o ORG_NAME -w WORKFLOW_FILE -l LOG_FILE
27+
gh add-files code-scanning
28+
Add / Update the codeql.yml file in a repository via a PR
29+
30+
Usage:
31+
add-files code-scanning [flags]
32+
33+
Flags:
34+
-c, --csv string specify the location of csv file
35+
-f, --force force enable code scanning advanced setup or update the existing code scanning workflow file
36+
-h, --help help for code-scanning
37+
-l, --log string specify the path where the log file will be saved (default "gh-add-files.log")
38+
-o, --organization string specify Organisation to implement code scanning
39+
-t, --template string specify the path to the code scanning workflow template file
40+
-w, --workflow string specify the path to the code scanning workflow file
2841
```
29-
The following flags are mandatory:
30-
- `-o` - specifies the organisation you want to roll out code scanning to
31-
- `-w` - specify the path to the code scanning file
32-
- `-l` - specify the path where the log file will be saved
3342

34-
This command operates by traversing all the repositories within the organization. For each repository, it performs the following steps:
43+
The code-scanning command accepts the following three input sources:
44+
45+
- `c` - A CSV file containing a list of repositories to enable code scanning for. The CSV file's format is straightforward, consisting of a single column where each row specifies a repository in the format `{OWNER}/{REPO}`. No heading is required for this csv. You can refer to the examples/test.csv file in this repository for an illustration.
46+
- `o` - An organization to enable code scanning for. This will enable code scanning for all repositories within the organization.
47+
- standard input - A space separated list of repositories to enable code scanning for.
3548

36-
1. Creates a new branch, naming it gh-cli/codescanningworkflow, branching off the default branch.
49+
You cannot specify more than one of these input sources.
3750

38-
2. Commits the workflow file specified by the user using the `-w` flag.
51+
#### codeql.yml
3952

40-
3. Initiates a pull request to the default branch.
53+
There are two ways to push a `codeql.yml` file to your repository:
4154

42-
In case of any errors during this process, it logs the error but continues to the next repository.
55+
- You can specify the path to a `codeql.yml` file using the `-w` flag. This file will be pushed to the repository as is.
56+
- You can specify the path to a `codeql.yml` template file using the `-t` flag. This template file will be used to generate a `codeql.yml` file, which will then be pushed to the repository. The template file is used if you want to dynamically generate a `codeql.yml` where the default branch will be different for every repo. The tool will determine the default branch for the repository and update the template file for the repository.
4357

44-
After the command completes its execution, it is strongly recommended to review the log file for any potential errors. Once any identified issues are rectified, you can rerun the command.
58+
#### Force Flag
4559

46-
### Code Scanning Enable Repository
60+
The `-f` flag allows you to force enable code scanning advanced setup or update the existing code scanning workflow file. If default setup is currently enabled or if advanced setup is already enabled in the repository, this flag will disable default setup. If advanced setup is already enabled, this flag will open a PR to update the file. repository.
4761

48-
You have the option to incorporate a code scanning workflow file into multiple repositories within an organization, as defined by a CSV file. The CSV file's format is straightforward, consisting of a single column where each row specifies a repository in the format `{OWNER}/{REPO}`. No heading is required for this csv. You can refer to the examples/test.csv file in this repository for an illustration.
62+
#### Usage Examples
4963

50-
You can run the following command:
64+
To enable code scanning for all repositories within an organization, run the following command:
5165
```bash
52-
gh add-files code-scanning-enable-repo -o ORGANISATION -w WORKFLOW_FILE -l LOG_FILE -c CSV_FILE
66+
gh add-files code-scanning -o ORG_NAME -w WORKFLOW_FILE
5367
```
54-
The following flags are mandatory:
55-
- `-o` - specifies the organisation you want to roll out code scanning to
56-
- `-w` - specify the path to the code scanning file
57-
- `-l` - specify the path where the log file will be saved
58-
- `-c` - specify the location of the csv file
59-
6068

61-
This command operates by traversing all the repositories specified in the csv within the organization. For each repository, it performs the following steps:
62-
63-
1. Creates a new branch, naming it gh-cli/codescanningworkflow, branching off the default branch.
64-
65-
2. Commits the workflow file specified by the user using the `-w` flag.
66-
67-
3. Initiates a pull request to the default branch.
69+
To enable code scanning for a list of repositories specified in a CSV file, run the following command:
70+
```bash
71+
gh add-files code-scanning -c CSV_FILE -w WORKFLOW_FILE
72+
```
6873

69-
In case of any errors during this process, it logs the error but continues to the next repository.
74+
To enable code scanning for a list of repositories specified in standard input, run the following command:
75+
```bash
76+
gh add-files code-scanning -w WORKFLOW_FILE ORG/REPO1 ORG/REPO2
77+
```
7078

71-
After the command completes its execution, it is strongly recommended to review the log file for any potential errors. Once any identified issues are rectified, you can rerun the command.
79+
To enable code scanning for all repositories within an organization using a template file, run the following command:
80+
```bash
81+
gh add-files code-scanning -o ORG_NAME -t TEMPLATE_FILE
82+
```
7283

7384
### Delete Branch
7485

cmd/codescanning.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func init() {
3939
var codeScanningCmd = &cobra.Command{
4040
Use: "code-scanning",
4141
Short: "Add workflow files to enable code scanning",
42-
Long: "Creates branch `code-scanning-automated` on each repo in organisation and checks in workflow file defined in `--workflow` flag",
42+
Long: "Add / Update the codeql.yml file in a repository via a PR",
4343
Run: func(cmd *cobra.Command, args []string) {
4444

4545
//set up logging

0 commit comments

Comments
 (0)