|
18 | 18 | import itertools
|
19 | 19 | import logging
|
20 | 20 | import os
|
| 21 | +import subprocess |
21 | 22 | from typing import Iterable, Mapping, Optional
|
22 | 23 |
|
23 | 24 | import dateutil # type: ignore
|
@@ -173,7 +174,31 @@ def download_artifact(self, artifact_id: int):
|
173 | 174 | logging.debug('Downloading artifact %d', artifact_id)
|
174 | 175 | try:
|
175 | 176 | assert self.ghapi
|
176 |
| - return self.ghapi.actions.download_artifact(artifact_id, 'zip') |
| 177 | + |
| 178 | + # It seems like github artifact download is at least partially broken |
| 179 | + # (see https://github.com/project-chip/connectedhomeip/issues/32656) |
| 180 | + # |
| 181 | + # This makes `self.ghapi.actions.download_artifact` not work |
| 182 | + # |
| 183 | + # Oddly enough downloading via CURL seems ok |
| 184 | + owner = self.config['github.owner'] |
| 185 | + repo = self.config['github.repo'] |
| 186 | + token = self.config['github.token'] |
| 187 | + |
| 188 | + download_url = f"https://api.github.com/repos/{owner}/{repo}/actions/artifacts/{artifact_id}/zip" |
| 189 | + |
| 190 | + # Follow https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28#download-an-artifact |
| 191 | + return subprocess.check_output( |
| 192 | + [ |
| 193 | + 'curl', |
| 194 | + '-L', |
| 195 | + '-H', 'Accept: application/vnd.github+json', |
| 196 | + '-H', f'Authorization: Bearer {token}', |
| 197 | + '-H', 'X-GitHub-Api-Version: 2022-11-28', |
| 198 | + '--output', '-', |
| 199 | + download_url |
| 200 | + ] |
| 201 | + ) |
177 | 202 | except Exception as e:
|
178 | 203 | logging.error('Failed to download artifact %d: %s', artifact_id, e)
|
179 | 204 | return None
|
|
0 commit comments