【问题标题】:GitHub actions repository_dispatch event POST request not working due to organisation repository由于组织存储库,GitHub 操作 repository_dispatch 事件 POST 请求不起作用
【发布时间】:2021-10-08 03:40:08
【问题描述】:

我正在尝试触发 GitHub 操作工作流,该工作流位于我的组织存储库中,我是组织的所有者

我正在尝试使用以下 POST 请求触发

curl -H "Accept: application/vnd.github+json" -H "Authorization: token " --request POST --data '{"event_type": "do-something"}' https://api.github.com/repos/USER/REPO/dispatches

但我收到以下消息

{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/repos#create-a-repository-dispatch-event"
}

我的工作流程

name: Node.js CI

on:
  repository_dispatch:
  schedule:
    - cron: '5 12 * * 0'

jobs:
  build:
    runs-on: ubuntu-latest

我认为因为它不在我的帐户中,而是在组织帐户中,这就是它可能给出此错误的原因。 任何解决方法都会有所帮助。

【问题讨论】:

  • 如果repo在组织下,URL不应该包括ORGANISATION/REPO而不是USER/REPO吗?

标签: github github-actions dispatch


【解决方案1】:

token - repo 范围内的 GitHub Personal Access Token。 验证您的令牌是否具有 repo 的完整范围。

curl 'https://api.github.com/repos/USER/REPO/dispatches' --request POST \
-H 'Accept: application/vnd.github.everest-preview+json' \
-H 'Content-Type: application/javascript' \
-H 'Authorization: Bearer token' \
--data-raw '{
    "event_type": "do-something",
    "client_payload": { "text": "my custom text here" }
}'

【讨论】:

    猜你喜欢
    • 2019-12-27
    • 1970-01-01
    • 2018-12-25
    • 1970-01-01
    • 2016-03-27
    • 2017-01-05
    • 2016-11-05
    • 2013-06-01
    相关资源
    最近更新 更多