Skip to content

Commit 82c6111

Browse files
committed
initial commit
1 parent ebeb249 commit 82c6111

7 files changed

Lines changed: 1779 additions & 4 deletions

File tree

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflow will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
# This workflow uses actions that are not certified by GitHub.
5+
# They are provided by a third-party and are governed by
6+
# separate terms of service, privacy policy, and support
7+
# documentation.
8+
9+
name: Upload Python Package
10+
11+
on:
12+
release:
13+
types: [published]
14+
15+
jobs:
16+
deploy:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.11'
24+
cache-dependency-path: requirements.txt
25+
- name: Install dependencies
26+
run: |
27+
python -m pip install --upgrade pip
28+
pip install build
29+
- name: Build package
30+
run: python -m build
31+
- name: Publish package
32+
uses: pypa/gh-action-pypi-publish@release/v1
33+
with:
34+
user: __token__
35+
password: ${{ secrets.PYPI_API_TOKEN }}

LICENSE

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
BSD 3-Clause License
2+
3+
Copyright (c) 2023-, Daniel Moran.
4+
5+
Redistribution and use in source and binary forms, with or without
6+
modification, are permitted provided that the following conditions are met:
7+
8+
1. Redistributions of source code must retain the above copyright notice, this
9+
list of conditions and the following disclaimer.
10+
11+
2. Redistributions in binary form must reproduce the above copyright notice,
12+
this list of conditions and the following disclaimer in the documentation
13+
and/or other materials provided with the distribution.
14+
15+
3. Neither the name of the copyright holder nor the names of its
16+
contributors may be used to endorse or promote products derived from
17+
this software without specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

gha-cli/__init__.py

Whitespace-only changes.

ghautils.py renamed to gha-cli/ghautils.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ def parse_args() -> argparse.Namespace:
1414
help='GitHub token to use, by default will use GITHUB_TOKEN environment variable')
1515
subcommands = parser.add_subparsers(dest='command', required=True)
1616
list_wfs_cmd_parser = subcommands.add_parser('list-workflows', help='List github workflows')
17+
list_wfs_cmd_parser.add_argument('--local-only', action='store_true', dest='local_only',
18+
help='Show only workflows stored in the repository')
1719
list_actions_cmd_parser = subcommands.add_parser('list-actions', help='List actions in a workflow')
1820
list_actions_cmd_parser.add_argument('workflow_path', help='Workflow path')
1921
update_gha_cmd_parser = subcommands.add_parser('update', help='Update actions in github workflows')
@@ -31,11 +33,13 @@ def __init__(self, github_token: Optional[str]):
3133
raise ValueError('GITHUB_TOKEN must be set')
3234
self.client = Github(login_or_token=github_token)
3335

34-
def get_github_workflows(self, repo_name: str) -> List[Workflow]:
36+
def get_github_workflows(self, repo_name: str, local_only: bool = False) -> List[Workflow]:
3537
if repo_name in self.workflows:
3638
return list(self.workflows[repo_name].values())
3739
repo = self.client.get_repo(repo_name)
3840
workflows = list(repo.get_workflows())
41+
if local_only:
42+
workflows = list(filter(lambda item: item.path.startswith('.github/'), workflows))
3943
self.workflows[repo_name] = {wf.path: wf for wf in workflows}
4044
return workflows
4145

@@ -57,7 +61,8 @@ def get_workflow_actions(self, repo_name: str, workflow_path: str) -> Set[str]:
5761

5862
def check_for_updates(self, action_name: str) -> Optional[str]:
5963
"""Check whether an action has update, and return the latest version if it does
60-
syntax for uses: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses
64+
syntax for uses:
65+
https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_iduses
6166
"""
6267
if '@' not in action_name:
6368
return None

0 commit comments

Comments
 (0)