Skip to content

Commit fa4797b

Browse files
authored
Adding support pull request events (#14)
1 parent 0a048b3 commit fa4797b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ markdown_overview_temp.md
1717
markdown_security_temp.md
1818
.DS_Store
1919
*.pyc
20-
test.py
20+
test.py
21+
*.cpython-312.pyc

socketsecurity/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__author__ = 'socket.dev'
2-
__version__ = '1.0.0'
2+
__version__ = '1.0.1'

socketsecurity/core/github.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
global committer
2525
global gh_api_token
2626
global github_repository_owner
27+
global event_action
2728

2829
github_variables = [
2930
"GITHUB_SHA",
@@ -40,7 +41,8 @@
4041
"GITHUB_ACTOR",
4142
"GITHUB_ENV",
4243
"GH_API_TOKEN",
43-
"GITHUB_REPOSITORY_OWNER"
44+
"GITHUB_REPOSITORY_OWNER",
45+
"EVENT_ACTION"
4446
]
4547

4648
for env in github_variables:
@@ -80,6 +82,7 @@ class Github:
8082
github_env: str
8183
api_token: str
8284
project_id: int
85+
event_action: str
8386

8487
def __init__(self):
8588
self.commit_sha = github_sha
@@ -100,6 +103,7 @@ def __init__(self):
100103
self.github_env = github_env
101104
self.api_token = gh_api_token
102105
self.project_id = 0
106+
self.event_action = event_action
103107
if self.api_token is None:
104108
print("Unable to get Github API Token from GH_API_TOKEN")
105109
sys.exit(2)
@@ -111,12 +115,18 @@ def check_event_type() -> str:
111115
event_type = "main"
112116
else:
113117
event_type = "diff"
118+
elif github_event_name.lower() == "pull_request":
119+
if event_action is not None and event_action != "" and event_action.lower() == "opened":
120+
event_type = "diff"
121+
else:
122+
log.info(f"Pull Request Action {event_action} is not a supported type")
123+
sys.exit(0)
114124
elif github_event_name.lower() == "issue_comment":
115125
event_type = "comment"
116126
else:
117127
event_type = None
118128
log.error(f"Unknown event type {github_event_name}")
119-
sys.exit(1)
129+
sys.exit(0)
120130
return event_type
121131

122132
@staticmethod

0 commit comments

Comments
 (0)