def download_artifact(
    owner: str, repo: str, run_id: str, artifact_name: str, gh_token: str):
    """Download artifact by name from a run id
    Args:
        owner: Owner of the repo.
        repo: The name of the repository.
        run_id: The id of the action run that created the artifact.
        artifact_name: The name of the artifact to download.
        gh_token: The token used to download artifacts
    """

    headers = {
        "Accept": "application/vnd.github+json",
        "Authorization": f"Bearer {gh_token}",
        "X-GitHub-Api-Version": "2022-11-28"
    }

    artifacts = requests.get(
        WORKFLOW_RUN_ENDPOINT.format(owner=owner, repo=repo, run_id=run_id),
        headers=headers
    ).json()
    artifact_id = next((artifact['id'] for artifact in artifacts['artifacts'] if artifact['name'] == artifact_name), None)

    if not artifact_id:
        raise ValueError(f"Cannot find {artifact_name}! {artifacts} {owner} {repo} {run_id}")

    download = requests.get(
        ARTIFACT_DOWNLOAD_ENDPOINT.format(artifact_id=artifact_id, owner=owner, repo=repo,),
        headers=headers
    )
    with open(f"{artifact_name}.zip", "wb") as f:
        f.write(download.content)

    return f"{artifact_name}.zip"
Download artifact by name from a run id
    Args:
        owner: Owner of the repo.
        repo: The name of the repository.
        run_id: The id of the action run that created the artifact.
        artifact_name: The name of the artifact to download.
        gh_token: The token used to download artifacts
    
scripts/download_artifacts.py