Ram*_*ros 9 github-actions github-actions-runners
我想在工作流程中创建一个虚拟机并设置为自托管运行程序。目前,阻碍我的是缺乏为我提供 Runner Token 的 API。如果存在,我可以创建该实例并将其注册为运行程序,以便能够在下一个作业中使用它。
现在有人有办法获得跑步者令牌吗?
sma*_*c89 12
看起来他们终于创建了 runner api。请参阅此处的 API规范。
他们现在还提供了有关如何执行此操作的示例片段。有关完整示例,请参阅此处发布的其他答案。
目前,您必须使用此处找到的指南手动创建实例。
据github 工作人员称,有计划最终添加一个用于生成运行者代币的 api,但没有透露何时会发生这种情况的时间表。
路线图上有一个用于此目的的 API。我目前没有可以分享的时间表。但当可用时,我们将发布到变更日志。
并澄清有关 PAT/跑步者代币的一些混乱。通过 UI 提供的跑步者令牌是临时令牌,会在 60 分钟后过期。它只有注册跑步者的能力。
PAT 无法注册跑步者。
用于创建注册令牌的 API 已经可用:
使用以下 JavaScript 代码,您可以在 GitHub 操作内创建 GitHub 注册令牌:
const core = require('@actions/core');
const github = require('@actions/github');
async function getRegistrationToken() {
const githubToken = core.getInput('github_token'); // the GitHub Secret Token provided as an input of your GitHub Action using ${{ secrets.GITHUB_TOKEN }}
const octokit = github.getOctokit(githubToken);
const response = await octokit.request('POST /repos/{owner}/{repo}/actions/runners/registration-token', {
owner: github.context.repo.owner, // the value is taken from the environment variable GITHUB_REPOSITORY which is provided by the GitHub Action during runtime
repo: github.context.repo.repo, // the value is taken from the environment variable GITHUB_REPOSITORY which is provided by the GitHub Action during runtime
});
return response.data.token;
}
module.exports = {
getRegistrationToken,
};
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19755 次 |
| 最近记录: |