Plugin setup: Cannot set property 'createOrUpdateFiles' of undefined
solarmosaic-kflorence opened this issue · 3 comments
solarmosaic-kflorence commented
Using the instructions provided on https://github.com/actions/toolkit/tree/main/packages/github#extending-the-octokit-instance:
const github = require("@actions/github");
const { GitHub, getOctokitOptions } = require("@actions/github/lib/utils");
const octokitCommitMultipleFiles = require("octokit-commit-multiple-files");
function getOctokit(githubToken) {
// I believe this is the same as Oktokit.plugin()
const octokit = GitHub.plugin(octokitCommitMultipleFiles);
return new octokit(getOctokitOptions(githubToken, { userAgent }));
}
When getOctokit(token)
is invoked, it results in an error: Cannot set property 'createOrUpdateFiles' of undefined
.
solarmosaic-kflorence commented
For now, the workaround is:
const octokitCommitMultipleFiles = require("octokit-commit-multiple-files/create-or-update-files");
const octokit = github.getOctokit(githubToken, { userAgent });
await octokitCommitMultipleFiles(octokit.rest, { ... });
Note octokit.rest
instead of just octokit
since this project refers to things like octokit.git
but that property seems to only exist at octokit.rest.git
in the client returned by @actions/github
.
mheap commented
This is related to the change in v18.5.0
where the methods were moved to the rest
namespace. Version 4.0.0 will be released soon which resolves this issue
mheap commented
v4.0.0 has now been released