Files
automatisch/packages/backend/src/apps/github/triggers/new-repository.ts
Ali BARIN af348714f8 feat: add new pull request trigger in GitHub (#301)
* feat: add new pull request trigger in GitHub
2022-04-23 02:14:54 +03:00

33 lines
800 B
TypeScript

import { Octokit } from 'octokit';
import { DateTime } from 'luxon';
import { IJSONObject } from '@automatisch/types';
export default class NewRepository {
client?: Octokit;
connectionData?: IJSONObject;
constructor(connectionData: IJSONObject) {
if (connectionData.accessToken) {
this.client = new Octokit({
auth: connectionData.accessToken as string,
});
}
}
async run(startTime: Date) {
const options = {
since: DateTime.fromJSDate(startTime).toISO(),
};
return await this.client.paginate(this.client.rest.repos.listForAuthenticatedUser, options);
}
async testRun() {
const options = {
per_page: 1,
};
const { data: repos } = await this.client.rest.repos.listForAuthenticatedUser(options);
return repos;
}
}