【问题标题】:Searching for all repositories with *.yml files with GitHub GraphQL使用 GitHub GraphQL 搜索带有 *.yml 文件的所有存储库
【发布时间】:2021-10-08 23:37:06
【问题描述】:

我想查找组织中所有正在使用工作流文件的存储库以进行进一步分析。

如果我现在有了它的名称,我可以通过 GraphQL 搜索特定文件:

{
  search(query: "org:rajbos", type: REPOSITORY, last: 100) {
    repositoryCount
    pageInfo {
      endCursor
      startCursor
    }
    edges {
      node{
        ... on Repository {
          nameWithOwner
          url
          object(expression: "HEAD:README.md") {
            ... on Blob {
              byteSize
            }
          }
        }
      }
    }
  }
}

如何在特定目录中搜​​索 *.yml 文件?我不知道前面的文件名。

存储库(所有者:“someOwner”,名称:“some-Repo”)

【问题讨论】:

    标签: github graphql


    【解决方案1】:

    发现您可以在某个位置查询所有存储库的文件,然后过滤该设置的客户端:

    query {
     search(first: 100, type: REPOSITORY, query: "org:rajbos") {
       repositoryCount
        edges {       
          node {
            ... on Repository {  
              nameWithOwner
              object(expression: "main:.github/workflows/") {
                ... on Tree {
                  entries {
                    name
                  }
                }
              }
            }
          }
        }
      }
    }
    

    结果:

     {
              "node": {
                "nameWithOwner": "rajbos/github-fork-updater",
                "object": {
                  "entries": [
                    {
                      "name": "check-workflow.yml"
                    },
                    {
                      "name": "update-workflow.yml"
                    }
                  ]
                }
              }
            }
    

    【讨论】:

    • 注意:这不会给你任何分叉,因为这些在 Repository 对象中不可用:-(
    猜你喜欢
    • 2018-08-26
    • 2020-03-16
    • 2017-04-28
    • 1970-01-01
    • 1970-01-01
    • 2021-04-24
    • 1970-01-01
    • 2019-05-16
    • 1970-01-01
    相关资源
    最近更新 更多