TypeError: github.repos.createStatus is not a function
Closed this issue · 2 comments
stereobooster commented
Describe the bug
Function is not defined, but it is supposed to be according to API documentation
To Reproduce
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set preview status
uses: actions/github-script@v4.0.2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { payload } = context;
const sha = payload.pull_request && payload.pull_request.head
? payload.pull_request.head.sha
: context.sha;
await github.repos.createStatus({
...context.repo,
sha,
state: "success",
target_url: `...`,
description: "Preview is ready!",
});
Expected behavior
It should create status
Screenshots
Run actions/github-script@v4.0.2
debug: false
user-agent: actions/github-script
result-encoding: json
TypeError: github.repos.createStatus is not a function
Error: Unhandled error: TypeError: github.repos.createStatus is not a function
at eval (eval at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:2451:56), <anonymous>:7:20)
at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:2452:12)
at main (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:2505:26)
at Module.272 (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:2489:1)
at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:24:31)
at startup (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:43:19)
at /home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:49:18
at Object.<anonymous> (/home/runner/work/_actions/actions/github-script/v4.0.2/dist/index.js:52:10)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
Desktop (please complete the following information):
- OS: latest-ubuntu
- Browser none
- Version none
Smartphone (please complete the following information):
- Device: none
- OS: none
- Browser none
- Version none
Additional context
none
mayank99 commented
The correct name is createCommitStatus
and I think you also need to specify owner
. See https://octokit.github.io/rest.js/v18#repos-create-commit-status
stereobooster commented
@mayank99 thanks again. Yes, createCommitStatus
works.