我对 GitHub 工作流程/操作相当陌生,我的任务是获取当前与跑步者匹配的跑步者列表。 我在查看现有工作流程时看到了这个声明。
runs-on: ["self-hosted", "management-control-plane", "${{ needs.env.outputs.env }}"]
所以看起来就像是在说“在指定环境中找到一个具有指定标签“管理控制平面”的现有虚拟机。 所以,Github 作为其引用的某个地方的列表。
问题: 如何使用标签和环境查询虚拟机列表? 谢谢!
您可以使用 REST API 列出您的组织或存储库的所有运行程序。
这是来自 docs 的示例:
curl \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/orgs/ORG/actions/runners
{
"total_count": 2,
"runners": [
{
"id": 23,
"name": "linux_runner",
"os": "linux",
"status": "online",
"busy": true,
"labels": [
{
"id": 5,
"name": "self-hosted",
"type": "read-only"
},
{
"id": 7,
// etc...
可以在动作中使用 GH Cli:
- name: version
env:
GH_TOKEN: ${{ secrets.GH_CLI_TOKEN }}
run: |
gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/<ORG>/actions/runners