4

Let's say that we have the Github package registry repository https://maven.pkg.github.com/someOrganization . How can I cat the list of all packages in this repo into a txt file ?

Edric
  • 24,639
  • 13
  • 81
  • 91

1 Answers1

2

This can be done using Preview API for GitHub Packages. You can query it in GraphQL using:

query($login: String!) {
  organization(login:$login) {
    registryPackages(first:10, packageType:MAVEN) {
      nodes {
       name             
      }
    }
  }
}

This will output something like:

{
  "data": {
    "organization": {
      "registryPackages": {
        "nodes": [
          {
            "name": "package1"
          },
          {
            "name": "package2"
          }            
        ]
      }
    }
  }
}

At the time of writing this requires both:

  • Valid Token with org:read and packages:read
  • Accept header for preview API: application/vnd.github.packages-preview+json

Now because you want to do this over the command line, you could curling it. There's already a good answer on how to use curl to access GitHub's GraphQL API: https://stackoverflow.com/a/42021388/1174076

Hope this helps.

bitoiu
  • 6,893
  • 5
  • 38
  • 60