我有一个托管在 GitHub 组织中的私有 GitHub 存储库。\n该存储库包含带有选项的 GitHub 操作workflow_dispatch\n(参见GitHub 文档)。
操作 YAML 文件摘录:
\non:\n # Allows you to run this workflow manually from the Actions tab\n workflow_dispatch:\n\njobs:\n build:\n runs-on: ubuntu-latest\nRun Code Online (Sandbox Code Playgroud)\n我可以从 GitHub Actions 选项卡成功触发此操作。
\n不过,我希望能够通过POST对 GitHub API 的请求来触发此操作。\n这应该可以使用 GitHub API 实现。\n相关的 API 端点似乎如\n文档/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches中所述。
该文件进一步指出:
\n\n\n您必须使用具有存储库范围的访问令牌进行身份验证才能使用此端点。
\n
因此,在我的个人帐户设置中的“开发人员设置”\xe2\x86\x92“个人访问令牌”下,\n我创建了一个令牌并授予对所有“存储库”项以及“工作流”项的访问权限。
\n我已测试通过使用PostmanPOST发出请求来触发 GitHub Action 。\n为此,我根据\n GitHub 文档使用以下参数:curl
accept:(application/vnd.github.v3+json根据 …我有一个私有 GitHub 存储库,其中有一个 GitHub Action,它将在 Action 运行时创建的文件推送到存储库。从昨天(2022-04-12)开始,操作在以下步骤失败:
- name: Push data to repo
uses: github-actions-x/commit@v2.8
with:
push-branch: 'main'
commit-message: 'Add current data'
force-add: 'true'
files: *.zip
name: autoupdate
Run Code Online (Sandbox Code Playgroud)
运行此步骤会触发以下错误消息:
Command line: | /usr/bin/git checkout -B main
Stderr: | fatal: unsafe repository ('/github/workspace' is owned by someone else)
| To add an exception for this directory, call:
|
| git config --global --add safe.directory /github/workspace
Run Code Online (Sandbox Code Playgroud)
根据错误消息,我将以下内容添加到我的 GitHub Action 中:
- name: Fix issue with repository ownership
run: |
git config --global …Run Code Online (Sandbox Code Playgroud)