@octokit/types#GetResponseDataTypeFromEndpointMethod TypeScript Examples
The following examples show how to use
@octokit/types#GetResponseDataTypeFromEndpointMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: get-changed-files.ts From action-eslint with MIT License | 6 votes |
getChangedFiles = async (token: string): Promise<FileNamesList> => {
const octokit = getOctokit(token);
const pullRequest = context.payload.pull_request;
let filenames: FileNamesList = [];
if (!pullRequest?.number) {
const getCommitEndpointOptions = octokit.rest.repos.getCommit.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
ref: context.sha,
});
type ReposGetCommitResponse = GetResponseDataTypeFromEndpointMethod<typeof octokit.rest.repos.getCommit>;
const response: ReposGetCommitResponse[] = await octokit.paginate(getCommitEndpointOptions);
const filesArr = response.map((data) => data.files);
const filesChangedInCommit = filesArr.reduce((acc, val) => acc?.concat(val || []), []);
filenames = getFileNames(filesChangedInCommit as File[]);
} else {
const listFilesEndpointOptions = octokit.rest.pulls.listFiles.endpoint.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pullRequest.number,
});
type PullsListFilesResponse = GetResponseDataTypeFromEndpointMethod<typeof octokit.rest.pulls.listFiles>;
const filesChangedInPR: PullsListFilesResponse = await octokit.paginate(listFilesEndpointOptions);
filenames = getFileNames(filesChangedInPR as File[]);
}
return filenames;
}