feat(github): add list-labels dynamic data
This commit is contained in:
26
packages/backend/src/apps/github/data/list-labels/index.ts
Normal file
26
packages/backend/src/apps/github/data/list-labels/index.ts
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { IGlobalVariable } from '@automatisch/types';
|
||||||
|
import getRepoOwnerAndRepo from '../../common/get-repo-owner-and-repo';
|
||||||
|
import paginateAll from '../../common/paginate-all';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'List labels',
|
||||||
|
key: 'listLabels',
|
||||||
|
|
||||||
|
async run($: IGlobalVariable) {
|
||||||
|
const {
|
||||||
|
repoOwner,
|
||||||
|
repo,
|
||||||
|
} = getRepoOwnerAndRepo($.step.parameters.repo as string);
|
||||||
|
const firstPageRequest = $.http.get(`/repos/${repoOwner}/${repo}/labels`);
|
||||||
|
const response = await paginateAll($, firstPageRequest);
|
||||||
|
|
||||||
|
response.data = response.data.map((repo: { name: string }) => {
|
||||||
|
return {
|
||||||
|
value: repo.name,
|
||||||
|
name: repo.name,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return response;
|
||||||
|
},
|
||||||
|
};
|
Reference in New Issue
Block a user