|
2 | 2 | import asyncio |
3 | 3 | import dataclasses |
4 | 4 | import json |
| 5 | +import os |
5 | 6 | from pathlib import Path |
6 | 7 | from typing import Any, AsyncIterable, Dict, List, Optional, Union |
7 | 8 |
|
8 | 9 | import aiohttp |
9 | 10 | import semver |
| 11 | +from exceptions import ConfigurationError |
10 | 12 | from registry import Registry |
11 | 13 |
|
12 | 14 | REPO_ROOT = "https://raw.githubusercontent.com/bluerobotics/BlueOS-Extensions-Repository/master/" |
@@ -93,6 +95,12 @@ async def fetch_readme(url: str) -> str: |
93 | 95 | raise Exception(f"bad response type for readme: {resp.content_type}, expected text/plain") |
94 | 96 | return await resp.text() |
95 | 97 |
|
| 98 | + def raise_if_pull_request(self, exception: Exception): |
| 99 | + print(os.environ.get()) |
| 100 | + if os.environ.get("github.event_name", None) == "pull_request": |
| 101 | + raise exception |
| 102 | + print(exception) |
| 103 | + |
96 | 104 | async def all_repositories(self) -> AsyncIterable[RepositoryEntry]: |
97 | 105 | repos = self.repo_folder() |
98 | 106 | for repo in repos.glob("**/metadata.json"): |
@@ -144,6 +152,10 @@ async def run(self) -> None: |
144 | 152 | continue |
145 | 153 | raw_labels = await self.registry.fetch_labels(f"{repository.docker}:{tag}") |
146 | 154 | permissions = raw_labels.get("permissions", None) |
| 155 | + if not permissions: |
| 156 | + self.raise_if_pull_request( |
| 157 | + ConfigurationError("LABEL permissions is not found. please add it and try again") |
| 158 | + ) |
147 | 159 | website = raw_labels.get("website", None) |
148 | 160 | authors = raw_labels.get("authors", None) |
149 | 161 | docs = raw_labels.get("docs", None) |
|
0 commit comments