Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Trouble with CreateComment url path in js octokit api#489

Vroy1 started this conversation inGeneral
Discussion options

About creating comment in javascript on github action as this example code on the site :https://github.com/marketplace/actions/github-script

Here is the code :

- uses: actions/github-script@v7  id: my-script  with:    result-encoding: string    retries: 3    retry-exempt-status-codes: 400,401    script: |      github.rest.issues.get({        issue_number: context.issue.number,        owner: context.repo.owner,        repo: context.repo.repo,      })

On my side i do with an action script js file like this tutorial show :
https://docs.github.com/fr/actions/sharing-automations/creating-actions/creating-a-javascript-action

Because im doing it from a js file action script, this is not the same library .
Here is the js script that was needed to do the job with the @actions/github library.
from :https://octokit.github.io/rest.js/v21/

const core = require('@actions/core');const github = require('@actions/github');function createComment() {  try {    let options = {      body: "test Code Analysis",      issue_number: github.context.issue.number,      owner: github.context.issue.owner,      repo: github.context.repo.repo,    };    let octokit = github.getOctokit(core.getInput('user-personal-token'));    octokit.rest.issues.createComment(options);  } catch (error) {    core.setFailed(error.message);  }}createComment();

When i was sending the request, the url path was broken 404. All my property on path were replaced by comma like this :

https://api.github.com/repos/Owner,repo,/issues/issueNumber/comments

So I've used a var object named options instead of anonymous object and it started working.
And path became okay :
https://api.github.com/repos/Owner/repo/issues/issueNumber/comments

I'm sharing just in case someone got the same trouble.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
1 participant
@Vroy1

[8]ページ先頭

©2009-2025 Movatter.jp