feat: add new organization trigger in GitHub
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
96ede071cf
commit
6bee6bafa8
@@ -13,7 +13,11 @@ import {
|
|||||||
export default class Authentication implements IAuthentication {
|
export default class Authentication implements IAuthentication {
|
||||||
appData: IApp;
|
appData: IApp;
|
||||||
connectionData: IJSONObject;
|
connectionData: IJSONObject;
|
||||||
scopes: string[] = ['repo'];
|
scopes: string[] = [
|
||||||
|
'read:org',
|
||||||
|
'repo',
|
||||||
|
'user',
|
||||||
|
];
|
||||||
client: {
|
client: {
|
||||||
getWebFlowAuthorizationUrl: typeof getWebFlowAuthorizationUrl;
|
getWebFlowAuthorizationUrl: typeof getWebFlowAuthorizationUrl;
|
||||||
exchangeWebFlowCode: typeof exchangeWebFlowCode;
|
exchangeWebFlowCode: typeof exchangeWebFlowCode;
|
||||||
|
@@ -231,6 +231,22 @@
|
|||||||
"name": "Test trigger"
|
"name": "Test trigger"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "New organization",
|
||||||
|
"key": "newOrganization",
|
||||||
|
"interval": "15m",
|
||||||
|
"description": "Triggers when a new organization is created",
|
||||||
|
"substeps": [
|
||||||
|
{
|
||||||
|
"key": "chooseAccount",
|
||||||
|
"name": "Choose account"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "testStep",
|
||||||
|
"name": "Test trigger"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
import { IJSONObject } from '@automatisch/types';
|
import { IJSONObject } from '@automatisch/types';
|
||||||
import NewRepository from './triggers/new-repository';
|
import NewRepository from './triggers/new-repository';
|
||||||
|
import NewOrganization from './triggers/new-organization';
|
||||||
|
|
||||||
export default class Triggers {
|
export default class Triggers {
|
||||||
newRepository: NewRepository;
|
newRepository: NewRepository;
|
||||||
|
newOrganization: NewOrganization;
|
||||||
|
|
||||||
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
|
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
|
||||||
this.newRepository = new NewRepository(connectionData);
|
this.newRepository = new NewRepository(connectionData);
|
||||||
|
this.newOrganization = new NewOrganization(connectionData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,32 @@
|
|||||||
|
import { Octokit } from 'octokit';
|
||||||
|
import { IJSONObject } from '@automatisch/types';
|
||||||
|
|
||||||
|
export default class NewOrganization {
|
||||||
|
client?: Octokit;
|
||||||
|
baseOptions = {
|
||||||
|
per_page: 100,
|
||||||
|
};
|
||||||
|
|
||||||
|
constructor(connectionData: IJSONObject) {
|
||||||
|
if (
|
||||||
|
connectionData.consumerKey &&
|
||||||
|
connectionData.consumerSecret &&
|
||||||
|
connectionData.accessToken
|
||||||
|
) {
|
||||||
|
this.client = new Octokit({
|
||||||
|
auth: connectionData.accessToken as string,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async run() {
|
||||||
|
// TODO: implement pagination on undated entires
|
||||||
|
return await this.client.paginate(this.client.rest.orgs.listForAuthenticatedUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
async testRun() {
|
||||||
|
const { data: orgs } = await this.client.rest.orgs.listForAuthenticatedUser({ per_page: 1 });
|
||||||
|
|
||||||
|
return orgs;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user