Skip to content
This repository was archived by the owner on Aug 25, 2024. It is now read-only.

Commit 884bf8f

Browse files
committed
operations: innersource: action yml files: Remove YAML files that are not GitHub Actions by checking for runs: Keyword
Signed-off-by: John Andersen <[email protected]>
1 parent a818466 commit 884bf8f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

operations/innersource/dffml_operations_innersource/operations.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,27 @@ def groovy_files(self, repo: git_repository_checked_out.spec) -> dict:
9898
expand=["actions"],
9999
)
100100
def action_yml_files(self, repo: git_repository_checked_out.spec) -> dict:
101+
list_of_action_yml_files = list(
102+
pathlib.Path(repo.directory).rglob("**/action.yml")
103+
)
104+
# Remove YAML files that are not GitHub Actions (for example if someone
105+
# named a workflow action.yml).
106+
remove_paths = set()
107+
for action_path in list_of_action_yml_files:
108+
action_text = action_path.read_text(errors="backslashreplace")
109+
action_text = action_text.replace("\r", "")
110+
# Look for runs: at top level
111+
if not "runs:" in action_text.split("\n"):
112+
remove_paths.add(action_path)
113+
for remove_path in remove_paths:
114+
list_of_action_yml_files.remove(remove_path)
115+
# Conver to repo relative paths
101116
list_of_action_yml_files = list(
102117
map(
103118
str,
104119
relative_paths(
105120
repo.directory,
106-
pathlib.Path(repo.directory).rglob("**/action.yml")
121+
list_of_action_yml_files,
107122
),
108123
),
109124
)

0 commit comments

Comments
 (0)