Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Ground Controller Lvl 2
Message 1 of 4

lab: writing-javascript-actions ... error: github.Github is not a constructor

Solved! Go to Solution.

getting this error in my action output ##[error]github.Github is not a constructor 

 

const core = require("@actions/core");
const github = require("@actions/github");

async function run() {
    try {
      const issueTitle = core.getInput("issue-title");
      const jokeBody = core.getInput("joke");
      const token = core.getInput("repo-token");
  
      const octokit = new github.Github(token);
  
      const newIssue = await octokit.issues.create({
          repo: github.context.repo.repo,
          owner: github.context.repo.owner,
          title: issueTitle,
          body: jokeBody
      });
    } catch (err) {
        core.setFailed(err.message);
    }
  }
  
  run();

 

ps - i think there is an typo in your lab documentation - it had ...

 

  } catch (err) {
      core.setFailed(error.message);

error should be err ??

 

3 Replies
Highlighted
Ground Controller Lvl 2
Message 2 of 4

Re: lab: writing-javascript-actions ... error: github.Github is not a constructor

I found the error - the code should be 

 

const octokit = new github.GitHub(token);

the lab documentation has error / wrong code 

Highlighted
Solution
Moderator
Message 3 of 4

Re: lab: writing-javascript-actions ... error: github.Github is not a constructor

Hello @markharrisonlab! I took a look at the course repository, and couldn't quite find the bug you were talking about. BUT, we are always looking for contributions. If you'd like, please feel free to open a pull request against this open source course repository: https://github.com/githubtraining/write-javascript-actions/

Highlighted
Ground Controller Lvl 1
Message 4 of 4

Re: lab: writing-javascript-actions ... error: github.Github is not a constructor