Skip to content

Commit 20110b3

Browse files
authored
Automatically detect GitHub event action from event payload if not set in environment (#105)
- Update the Github logic to read the event action from the GITHUB_EVENT_PATH payload file if EVENT_ACTION is not set.
1 parent c28a138 commit 20110b3

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "hatchling.build"
66

77
[project]
88
name = "socketsecurity"
9-
version = "2.1.27"
9+
version = "2.1.28"
1010
requires-python = ">= 3.10"
1111
license = {"file" = "LICENSE"}
1212
dependencies = [

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__ = '2.1.27'
2+
__version__ = '2.1.28'

socketsecurity/core/scm/github.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ def from_env(cls, pr_number: Optional[str] = None) -> 'GithubConfig':
4747
# Add debug logging
4848
sha = os.getenv('GITHUB_SHA', '')
4949
log.debug(f"Loading SHA from GITHUB_SHA: {sha}")
50-
50+
event_action = os.getenv('EVENT_ACTION', None)
51+
if not event_action:
52+
event_path = os.getenv('GITHUB_EVENT_PATH')
53+
if event_path and os.path.exists(event_path):
54+
with open(event_path, 'r') as f:
55+
event = json.load(f)
56+
event_action = event.get('action')
5157
repository = os.getenv('GITHUB_REPOSITORY', '')
5258
owner = os.getenv('GITHUB_REPOSITORY_OWNER', '')
5359
if '/' in repository:
@@ -74,7 +80,7 @@ def from_env(cls, pr_number: Optional[str] = None) -> 'GithubConfig':
7480
env=os.getenv('GITHUB_ENV', ''),
7581
token=token,
7682
owner=owner,
77-
event_action=os.getenv('EVENT_ACTION'),
83+
event_action=event_action,
7884
headers={
7985
'Authorization': f"Bearer {token}",
8086
'User-Agent': 'SocketPythonScript/0.0.1',

0 commit comments

Comments
 (0)