Skip to content

Commit 104263e

Browse files
committed
Minor updates
1 parent 8b30344 commit 104263e

File tree

2 files changed

+72
-50
lines changed

2 files changed

+72
-50
lines changed

README.md

Lines changed: 66 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,71 @@ GitHub Actions CLI
44
The purpose of this tool is to work with your GitHub Actions workflows in your repositories.
55
It is complementary to the GitHub CLI.
66

7-
It is important `GITHUB_TOKEN` environment variable is set in order for it to work properly.
7+
# Basic usage
88

9-
So far, three main flows are supported:
9+
Run `github-actions-cli` within a directory which has a clone of a GitHub repository.
10+
The tool will list the GitHub actions workflows, the actions they use, the current versions they use, and the latest
11+
versions of the actions.
1012

11-
# List all workflows path and name in a specified repository.
13+
```text
14+
./.github/workflows/test.yml:
15+
actions/checkout v3 ==> v3.5.3
16+
release-drafter/release-drafter v5 ==> v5.24.0
17+
actions/setup-python v4 ==> v4.7.0
18+
./.github/workflows/publish.yml:
19+
pypa/gh-action-pypi-publish release/v1 ==> v1.8.8
20+
actions/checkout v3 ==> v3.5.3
21+
actions/setup-python v4 ==> v4.7.0
22+
```
23+
24+
# Supported use cases
25+
26+
```text
27+
Usage: github-actions-cli [OPTIONS] COMMAND [ARGS]...
28+
29+
Options:
30+
-repo TEXT Repository to analyze, can be a local directory or a
31+
{OWNER}/{REPO} format [default: .]
32+
--github-token TEXT GitHub token to use, by default will use GITHUB_TOKEN
33+
environment variable
34+
--help Show this message and exit.
35+
36+
Commands:
37+
list-actions List actions in a workflow
38+
list-workflows List workflows in repository
39+
update-actions Show actions required updates in repository workflows
40+
```
41+
42+
## `update-actions` List all actions that are out of date in a repository (Default)
43+
44+
List the latest versions of actions used in a repository workflows
45+
and potentially update the workflow files.
46+
47+
For example, running `github-actions-cli` without any parameters will look for workflows in the
48+
current directory (`.`), check whether there are updates required for the actions in the workflows
49+
it finds.
50+
51+
Another example, running on a remote repository, `github-actions-cli -repo cunla/fakeredis update-actions -u`,
52+
will look for the latest versions of the actions used in the repository cunla/fakeredis, and because of the `-u`
53+
flag, it will create a commit updating the workflows to the latest.
54+
55+
> Note:
56+
> Having `GITHUB_TOKEN` with permissions to make commits on the repository
57+
> is required in order to write to repository.
58+
59+
Parameters:
60+
61+
```text
62+
Usage: cli.py update-actions [OPTIONS]
63+
64+
Show actions required updates in repository workflows
65+
66+
Options:
67+
-u, --update Do not update, list only
68+
-commit-msg TEXT Commit msg, only relevant when remote repo
69+
```
70+
71+
## `list-workflows` List all workflows path and name in a specified repository.
1272

1373
Example:
1474

@@ -23,68 +83,27 @@ will return:
2383
.github/workflows/test.yml
2484
```
2585

26-
# List all actions `uses` in a workflow
86+
## `list-actions` List all actions `uses` in a workflow
2787

2888
Given a repo and a workflow path, return all actions in the workflow.
2989

3090
Example:
91+
3192
```shell
3293
github-actions-cli -repo cunla/fakeredis list-actions .github/workflows/test.yml
3394
```
3495

3596
Result
97+
3698
```text
3799
actions/checkout@v3
38100
./.github/actions/test-coverage
39101
release-drafter/release-drafter@v5
40102
actions/setup-python@v4
41103
```
42104

43-
# Update all actions in a repository workflows
44-
List the latest versions of actions used in a repository workflow and update the workflow files.
45-
46-
Example for local clone of repository:
47-
```shell
48-
github-actions-cli update-actions --dry-run
49-
```
50-
51-
or for remote repository without cloning:
52-
53-
```shell
54-
github-actions-cli -repo cunla/fakeredis update-actions --dry-run
55-
```
56-
57-
Result:
58-
```text
59-
./.github/workflows/test.yml:
60-
release-drafter/release-drafter v5 ==> v5.24.0
61-
actions/checkout v3 ==> v3.5.3
62-
actions/setup-python v4 ==> v4.7.0
63-
./.github/workflows/publish.yml:
64-
pypa/gh-action-pypi-publish release/v1 ==> v1.8.8
65-
actions/checkout v3 ==> v3.5.3
66-
actions/setup-python v4 ==> v4.7.0
67-
```
68-
69105
# Installation
70106

71107
```shell
72108
pip install github-actions-cli
73109
```
74-
75-
# Help messages
76-
77-
```text
78-
Usage: github-actions-cli [OPTIONS] COMMAND [ARGS]...
79-
80-
Options:
81-
-repo TEXT Repository to analyze
82-
--github-token TEXT GitHub token to use, by default will use GITHUB_TOKEN
83-
environment variable
84-
--help Show this message and exit.
85-
86-
Commands:
87-
list-actions List actions in a workflow
88-
list-workflows List workflows in repository
89-
update-actions List actions in a workflow
90-
```

gha_cli/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,12 @@ def _update_workflow_content(
149149

150150

151151
@click.group(invoke_without_command=True)
152-
@click.option('-repo', default='.', help='Repository to analyze')
153-
@click.option('--github-token', default=os.getenv('GITHUB_TOKEN'),
154-
help='GitHub token to use, by default will use GITHUB_TOKEN environment variable')
152+
@click.option(
153+
'-repo', default='.', show_default=True, type=str,
154+
help='Repository to analyze, can be a local directory or a {OWNER}/{REPO} format')
155+
@click.option(
156+
'--github-token', default=os.getenv('GITHUB_TOKEN'), type=str, show_default=False,
157+
help='GitHub token to use, by default will use GITHUB_TOKEN environment variable')
155158
@click.pass_context
156159
def cli(ctx, repo: str, github_token: Optional[str]):
157160
ctx.ensure_object(dict)

0 commit comments

Comments
 (0)