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

Commit

Permalink
operations: innersource: action yml files: Remove YAML files that are…
Browse files Browse the repository at this point in the history
… not GitHub Actions by checking for runs: Keyword

Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Jul 25, 2023
1 parent a818466 commit 884bf8f
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,27 @@ def groovy_files(self, repo: git_repository_checked_out.spec) -> dict:
expand=["actions"],
)
def action_yml_files(self, repo: git_repository_checked_out.spec) -> dict:
list_of_action_yml_files = list(
pathlib.Path(repo.directory).rglob("**/action.yml")
)
# Remove YAML files that are not GitHub Actions (for example if someone
# named a workflow action.yml).
remove_paths = set()
for action_path in list_of_action_yml_files:
action_text = action_path.read_text(errors="backslashreplace")
action_text = action_text.replace("\r", "")
# Look for runs: at top level
if not "runs:" in action_text.split("\n"):
remove_paths.add(action_path)
for remove_path in remove_paths:
list_of_action_yml_files.remove(remove_path)
# Conver to repo relative paths
list_of_action_yml_files = list(
map(
str,
relative_paths(
repo.directory,
pathlib.Path(repo.directory).rglob("**/action.yml")
list_of_action_yml_files,
),
),
)
Expand Down

0 comments on commit 884bf8f

Please sign in to comment.