Skip to content

Commit 48b865b

Browse files
committed
add special handling for historic actions allowance against branches
1 parent 8063dcc commit 48b865b

3 files changed

Lines changed: 20 additions & 1 deletion

File tree

actions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ bytedeco/javacpp-presets/.github/actions/*:
2727
dtolnay/rust-toolchain:
2828
stable:
2929
keep: true
30+
# 'stable' is a branch, not a Git SHA
31+
ignore_invalid_git_sha: true
3032
golangci/*:
3133
'*':
3234
keep: true
@@ -37,6 +39,8 @@ pypa/gh-action-pip-audit:
3739
pypa/gh-action-pypi-publish:
3840
release/v1*:
3941
keep: true
42+
# 'release/v1*' is a branch wildcard, not a Git SHA
43+
ignore_invalid_git_sha: true
4044
pytooling/actions/with-post-step:
4145
'*':
4246
keep: true

gateway/action_tags.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,12 @@ def verify_actions(actions: Path | ActionsYAML | str, log_to_console: bool = Tru
261261
else:
262262
result.failure(m, " ..")
263263
else:
264-
result.failure(f"GitHub action {name} references an invalid Git SHA '{ref}'", " ..")
264+
ignore_invalid_git_sha = details and 'ignore_invalid_git_sha' in details and details['ignore_invalid_git_sha'] == True
265+
if ignore_invalid_git_sha:
266+
result.warning(f"GitHub action {name} references an invalid Git SHA but 'ignore_invalid_git_sha' is set: will ignore invalid Git SHA '{ref}'", " ..")
267+
else:
268+
result.failure(f"GitHub action {name} references an invalid Git SHA '{ref}'", " ..")
269+
raise Exception("foo")
265270

266271
for req_tag, req_shas in requested_shas_by_tag.items():
267272
result.log(f" .. checking tag '{req_tag}'")

gateway/gateway.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ class RefDetails(TypedDict):
2525
expires_at: date
2626
keep: NotRequired[bool]
2727
tag: NotRequired[str]
28+
# Action tags check: Ignore invalid Git SHA and GitHub API errors.
29+
# Some actions are allowed to use branches.
30+
# This should really be used in only very exceptional cases
31+
# and MUST NEVER be used for new actions.
32+
ignore_invalid_git_sha: NotRequired[bool]
33+
# Action tags check: Ignore GitHub API errors in special situations,
34+
# when for example the repository has an IP allow list enabled preventing checks using the GH API
35+
# against such repositories. Sample error message in such cases:
36+
# 'Although you appear to have the correct authorization credentials, the `ScaCap` organization has an IP allow list enabled, and your IP address is not permitted to access this resource.'
37+
ignore_gh_api_errors: NotRequired[bool]
2838

2939

3040
ActionRefs = Dict[str, RefDetails]

0 commit comments

Comments
 (0)