Skip to content

Commit 5ea6955

Browse files
authored
Merge pull request #68 from legendu-net/push-rumyvtuwqoyr
Merge push-rumyvtuwqoyr Into main
2 parents e4234df + 207dc74 commit 5ea6955

3 files changed

Lines changed: 66 additions & 7 deletions

File tree

github_rest_api/actions/container/build_container_images.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import subprocess as sp
66
import sys
77
from typing import cast
8+
import yaml
89
from dulwich.repo import Repo
910
from dulwich.refs import Ref
1011
from dulwich.objects import Commit
@@ -209,11 +210,11 @@ def parse_args():
209210
)
210211
group.add_argument(
211212
"-f",
212-
"--file-image-dirs",
213-
dest="file_image_dirs",
213+
"--yaml-image-dirs",
214+
dest="yaml_image_dirs",
214215
default=None,
215216
metavar="FILE",
216-
help="Path to a file listing image directories to build, one per line.",
217+
help="Path to a YAML file containing a list of image dirs to build.",
217218
)
218219
parser.add_argument(
219220
"--paths-monitoring",
@@ -229,8 +230,17 @@ def parse_args():
229230
def _resolve_image_dirs(args: argparse.Namespace) -> list[str]:
230231
if args.image_dirs:
231232
return args.image_dirs
232-
with Path(args.file_image_dirs).open(encoding="utf-8") as fin:
233-
return [s for line in fin if (s := line.strip()) and not s.startswith("#")]
233+
with Path(args.yaml_image_dirs).open(encoding="utf-8") as fin:
234+
data = yaml.safe_load(fin)
235+
if data is None:
236+
return []
237+
if not isinstance(data, list) or not all(
238+
isinstance(item, str) for item in data
239+
):
240+
raise ValueError(
241+
f"{args.yaml_image_dirs} must contain a YAML list of strings."
242+
)
243+
return [s for item in data if (s := item.strip())]
234244

235245

236246
def main():

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ requires = [ "hatchling" ]
44

55
[project]
66
name = "github-rest-api"
7-
version = "0.37.1"
7+
version = "0.38.0"
88
description = "Simple wrapper of GitHub REST APIs."
99
readme = "README.md"
1010
authors = [ { name = "Ben Du", email = "longendu@yahoo.com" } ]
@@ -18,6 +18,7 @@ classifiers = [
1818
dependencies = [
1919
"dulwich>=0.25.1",
2020
"psutil>=5.9.4",
21+
"pyyaml>=6",
2122
"requests>=2.28.2",
2223
"tenacity>=9.1.4",
2324
"tomli-w>=1",

uv.lock

Lines changed: 49 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)