2023-01-27 03:22:44 -08:00
import type {
2019-06-23 03:35:23 -07:00
IDataObject ,
2023-03-06 08:33:32 -08:00
IExecuteFunctions ,
2024-02-14 07:29:09 -08:00
IHttpRequestMethods ,
2019-06-23 03:35:23 -07:00
INodeExecutionData ,
INodeType ,
2020-10-01 05:01:39 -07:00
INodeTypeDescription ,
2019-06-23 03:35:23 -07:00
} from 'n8n-workflow' ;
2023-01-27 03:22:44 -08:00
import { NodeOperationError } from 'n8n-workflow' ;
2019-06-23 03:35:23 -07:00
2022-08-17 08:50:24 -07:00
import { snakeCase } from 'change-case' ;
import { getFileSha , githubApiRequest , githubApiRequestAllItems } from './GenericFunctions' ;
2019-06-23 03:35:23 -07:00
2023-02-16 03:54:42 -08:00
import { getRepositories , getUsers } from './SearchFunctions' ;
2021-01-19 23:33:17 -08:00
2019-06-23 03:35:23 -07:00
export class Github implements INodeType {
description : INodeTypeDescription = {
2020-07-07 02:31:05 -07:00
displayName : 'GitHub' ,
2019-06-23 03:35:23 -07:00
name : 'github' ,
2021-01-19 23:33:17 -08:00
icon : 'file:github.svg' ,
2019-06-23 03:35:23 -07:00
group : [ 'input' ] ,
version : 1 ,
2021-01-19 23:33:17 -08:00
subtitle : '={{$parameter["operation"] + ": " + $parameter["resource"]}}' ,
2021-07-03 05:40:16 -07:00
description : 'Consume GitHub API' ,
2019-06-23 03:35:23 -07:00
defaults : {
2020-07-07 02:31:05 -07:00
name : 'GitHub' ,
2019-06-23 03:35:23 -07:00
} ,
inputs : [ 'main' ] ,
outputs : [ 'main' ] ,
credentials : [
{
name : 'githubApi' ,
required : true ,
2020-02-09 07:11:15 -08:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
authentication : [ 'accessToken' ] ,
2020-02-09 07:11:15 -08:00
} ,
} ,
} ,
{
2020-02-09 15:39:14 -08:00
name : 'githubOAuth2Api' ,
2020-02-09 07:11:15 -08:00
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
authentication : [ 'oAuth2' ] ,
2020-02-09 07:11:15 -08:00
} ,
} ,
} ,
2019-06-23 03:35:23 -07:00
] ,
properties : [
2020-02-09 07:11:15 -08:00
{
displayName : 'Authentication' ,
name : 'authentication' ,
type : 'options' ,
options : [
{
name : 'Access Token' ,
value : 'accessToken' ,
} ,
{
name : 'OAuth2' ,
2020-05-31 10:24:14 -07:00
value : 'oAuth2' ,
2020-02-09 07:11:15 -08:00
} ,
] ,
default : 'accessToken' ,
} ,
2019-07-14 07:50:26 -07:00
{
displayName : 'Resource' ,
name : 'resource' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
options : [
{
name : 'File' ,
value : 'file' ,
} ,
{
name : 'Issue' ,
value : 'issue' ,
} ,
2022-06-20 07:54:01 -07:00
{
name : 'Organization' ,
value : 'organization' ,
} ,
2019-07-14 07:50:26 -07:00
{
name : 'Release' ,
value : 'release' ,
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Repository' ,
value : 'repository' ,
} ,
2021-01-19 23:33:17 -08:00
{
name : 'Review' ,
value : 'review' ,
} ,
2019-07-14 07:50:26 -07:00
{
name : 'User' ,
value : 'user' ,
} ,
] ,
default : 'issue' ,
} ,
// ----------------------------------
// operations
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'organization' ] ,
2022-05-30 22:54:32 -07:00
} ,
2022-05-03 03:59:00 -07:00
} ,
2022-05-04 07:33:46 -07:00
options : [
2022-05-30 22:54:32 -07:00
{
2022-05-31 00:11:50 -07:00
name : 'Get Repositories' ,
2022-05-30 22:54:32 -07:00
value : 'getRepositories' ,
description : 'Returns all repositories of an organization' ,
2022-07-10 13:50:51 -07:00
action : 'Get repositories for an organization' ,
2022-05-30 22:54:32 -07:00
} ,
2022-05-04 07:33:46 -07:00
] ,
2022-05-05 08:31:26 -07:00
default : 'getRepositories' ,
2022-05-30 22:54:32 -07:00
} ,
2022-05-03 03:59:00 -07:00
2019-06-23 03:35:23 -07:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'issue' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
2019-06-23 03:35:23 -07:00
options : [
{
2019-07-14 07:50:26 -07:00
name : 'Create' ,
value : 'create' ,
2022-05-06 14:01:25 -07:00
description : 'Create a new issue' ,
2022-07-10 13:50:51 -07:00
action : 'Create an issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Create Comment' ,
value : 'createComment' ,
2022-05-06 14:01:25 -07:00
description : 'Create a new comment on an issue' ,
2022-07-10 13:50:51 -07:00
action : 'Create a comment on an issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Edit' ,
value : 'edit' ,
2022-05-06 14:01:25 -07:00
description : 'Edit an issue' ,
2022-07-10 13:50:51 -07:00
action : 'Edit an issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get the data of a single issue' ,
2022-07-10 13:50:51 -07:00
action : 'Get an issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Lock' ,
value : 'lock' ,
2022-05-06 14:01:25 -07:00
description : 'Lock an issue' ,
2022-07-10 13:50:51 -07:00
action : 'Lock an issue' ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-14 07:50:26 -07:00
] ,
default : 'create' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'file' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
options : [
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
name : 'Create' ,
value : 'create' ,
2022-05-06 14:01:25 -07:00
description : 'Create a new file in repository' ,
2022-07-10 13:50:51 -07:00
action : 'Create a file' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Delete' ,
value : 'delete' ,
2022-05-06 14:01:25 -07:00
description : 'Delete a file in repository' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a file' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Edit' ,
value : 'edit' ,
2022-05-06 14:01:25 -07:00
description : 'Edit a file in repository' ,
2022-07-10 13:50:51 -07:00
action : 'Edit a file' ,
2019-06-23 03:35:23 -07:00
} ,
{
2019-07-14 07:50:26 -07:00
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get the data of a single file' ,
2022-07-10 13:50:51 -07:00
action : 'Get a file' ,
2022-02-04 11:18:30 -08:00
} ,
{
name : 'List' ,
value : 'list' ,
2022-05-06 14:01:25 -07:00
description : 'List contents of a folder' ,
2022-07-10 13:50:51 -07:00
action : 'List a file' ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-14 07:50:26 -07:00
] ,
default : 'create' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'repository' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
options : [
2019-09-11 14:46:17 -07:00
{
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get the data of a single repository' ,
2022-07-10 13:50:51 -07:00
action : 'Get a repository' ,
2019-09-11 14:46:17 -07:00
} ,
2019-07-14 07:50:26 -07:00
{
name : 'Get Issues' ,
value : 'getIssues' ,
2022-05-06 14:01:25 -07:00
description : 'Returns issues of a repository' ,
2022-07-10 13:50:51 -07:00
action : 'Get issues of a repository' ,
2019-06-23 03:35:23 -07:00
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Get License' ,
value : 'getLicense' ,
2022-08-17 08:50:24 -07:00
description :
"Returns the contents of the repository's license file, if one is detected" ,
2022-07-10 13:50:51 -07:00
action : 'Get the license of a repository' ,
2022-06-03 10:23:49 -07:00
} ,
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
name : 'Get Profile' ,
value : 'getProfile' ,
2022-05-31 00:11:50 -07:00
description :
'Get the community profile of a repository with metrics, health score, description, license, etc' ,
2022-07-10 13:50:51 -07:00
action : 'Get the profile of a repository' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'List Popular Paths' ,
value : 'listPopularPaths' ,
2022-05-06 14:01:25 -07:00
description : 'Get the top 10 popular content paths over the last 14 days' ,
2022-07-10 13:50:51 -07:00
action : 'List popular paths in a repository' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'List Referrers' ,
value : 'listReferrers' ,
2022-05-06 14:01:25 -07:00
description : 'Get the top 10 referrering domains over the last 14 days' ,
2022-07-10 13:50:51 -07:00
action : 'List the top referrers of a repository' ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-14 07:50:26 -07:00
] ,
default : 'getIssues' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'user' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
options : [
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
name : 'Get Repositories' ,
value : 'getRepositories' ,
2022-05-06 14:01:25 -07:00
description : 'Returns the repositories of a user' ,
2022-08-17 08:50:24 -07:00
action : "Get a user's repositories" ,
2019-06-23 03:35:23 -07:00
} ,
2021-01-23 04:11:00 -08:00
{
name : 'Invite' ,
value : 'invite' ,
2022-05-06 14:01:25 -07:00
description : 'Invites a user to an organization' ,
2022-07-10 13:50:51 -07:00
action : 'Invite a user' ,
2021-01-23 04:11:00 -08:00
} ,
2019-07-14 07:50:26 -07:00
] ,
default : 'getRepositories' ,
} ,
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2019-07-14 07:50:26 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'release' ] ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-14 07:50:26 -07:00
} ,
options : [
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
name : 'Create' ,
value : 'create' ,
2022-05-06 14:01:25 -07:00
description : 'Creates a new release' ,
2022-07-10 13:50:51 -07:00
action : 'Create a release' ,
2019-06-23 03:35:23 -07:00
} ,
2022-06-03 10:23:49 -07:00
{
name : 'Delete' ,
value : 'delete' ,
description : 'Delete a release' ,
2022-07-10 13:50:51 -07:00
action : 'Delete a release' ,
2022-06-03 10:23:49 -07:00
} ,
2021-04-09 22:54:05 -07:00
{
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get a release' ,
2022-07-10 13:50:51 -07:00
action : 'Get a release' ,
2021-04-09 22:54:05 -07:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-04-09 22:54:05 -07:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many repository releases' ,
2022-09-08 08:10:13 -07:00
action : 'Get many releases' ,
2021-04-09 22:54:05 -07:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-05-06 14:01:25 -07:00
description : 'Update a release' ,
2022-07-10 13:50:51 -07:00
action : 'Update a release' ,
2021-04-09 22:54:05 -07:00
} ,
2019-06-23 03:35:23 -07:00
] ,
2019-07-14 07:50:26 -07:00
default : 'create' ,
2019-06-23 03:35:23 -07:00
} ,
2021-01-19 23:33:17 -08:00
{
displayName : 'Operation' ,
name : 'operation' ,
type : 'options' ,
2022-05-20 14:47:24 -07:00
noDataExpression : true ,
2021-01-19 23:33:17 -08:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
options : [
{
name : 'Create' ,
value : 'create' ,
2022-05-06 14:01:25 -07:00
description : 'Creates a new review' ,
2022-07-10 13:50:51 -07:00
action : 'Create a review' ,
2021-01-19 23:33:17 -08:00
} ,
{
name : 'Get' ,
value : 'get' ,
2022-05-06 14:01:25 -07:00
description : 'Get a review for a pull request' ,
2022-07-10 13:50:51 -07:00
action : 'Get a review' ,
2021-01-19 23:33:17 -08:00
} ,
{
2022-09-07 07:51:14 -07:00
name : 'Get Many' ,
2021-01-19 23:33:17 -08:00
value : 'getAll' ,
2022-09-13 03:36:36 -07:00
description : 'Get many reviews for a pull request' ,
2022-09-08 08:10:13 -07:00
action : 'Get many reviews' ,
2021-01-19 23:33:17 -08:00
} ,
{
name : 'Update' ,
value : 'update' ,
2022-05-06 14:01:25 -07:00
description : 'Update a review' ,
2022-07-10 13:50:51 -07:00
action : 'Update a review' ,
2021-01-19 23:33:17 -08:00
} ,
] ,
default : 'create' ,
} ,
2019-07-14 07:50:26 -07:00
// ----------------------------------
// shared
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
displayName : 'Repository Owner' ,
name : 'owner' ,
2023-02-16 03:54:42 -08:00
type : 'resourceLocator' ,
default : { mode : 'list' , value : '' } ,
2019-06-23 03:35:23 -07:00
required : true ,
2023-02-16 03:54:42 -08:00
modes : [
{
displayName : 'Repository Owner' ,
name : 'list' ,
type : 'list' ,
placeholder : 'Select an owner...' ,
typeOptions : {
searchListMethod : 'getUsers' ,
searchable : true ,
searchFilterRequired : true ,
} ,
} ,
{
displayName : 'Link' ,
name : 'url' ,
type : 'string' ,
placeholder : 'e.g. https://github.com/n8n-io' ,
extractValue : {
type : 'regex' ,
regex : 'https:\\/\\/github.com\\/([-_0-9a-zA-Z]+)' ,
} ,
validation : [
{
type : 'regex' ,
properties : {
regex : 'https:\\/\\/github.com\\/([-_0-9a-zA-Z]+)(?:.*)' ,
errorMessage : 'Not a valid Github URL' ,
} ,
} ,
] ,
} ,
{
displayName : 'By Name' ,
name : 'name' ,
type : 'string' ,
placeholder : 'e.g. n8n-io' ,
validation : [
{
type : 'regex' ,
properties : {
regex : '[-_a-zA-Z0-9]+' ,
errorMessage : 'Not a valid Github Owner Name' ,
} ,
} ,
] ,
url : '=https://github.com/{{$value}}' ,
} ,
] ,
2021-01-23 04:11:00 -08:00
displayOptions : {
hide : {
2022-05-31 00:11:50 -07:00
operation : [ 'invite' ] ,
2021-01-23 04:11:00 -08:00
} ,
} ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Repository Name' ,
name : 'repository' ,
2023-02-16 03:54:42 -08:00
type : 'resourceLocator' ,
default : { mode : 'list' , value : '' } ,
2019-06-23 03:35:23 -07:00
required : true ,
2023-02-16 03:54:42 -08:00
modes : [
{
displayName : 'Repository Name' ,
name : 'list' ,
type : 'list' ,
placeholder : 'Select an Repository...' ,
typeOptions : {
searchListMethod : 'getRepositories' ,
searchable : true ,
} ,
} ,
{
displayName : 'Link' ,
name : 'url' ,
type : 'string' ,
placeholder : 'e.g. https://github.com/n8n-io/n8n' ,
extractValue : {
type : 'regex' ,
regex : 'https:\\/\\/github.com\\/(?:[-_0-9a-zA-Z]+)\\/([-_.0-9a-zA-Z]+)' ,
} ,
validation : [
{
type : 'regex' ,
properties : {
regex : 'https:\\/\\/github.com\\/(?:[-_0-9a-zA-Z]+)\\/([-_.0-9a-zA-Z]+)(?:.*)' ,
errorMessage : 'Not a valid Github Repository URL' ,
} ,
} ,
] ,
} ,
{
displayName : 'By Name' ,
name : 'name' ,
type : 'string' ,
placeholder : 'e.g. n8n' ,
validation : [
{
type : 'regex' ,
properties : {
regex : '[-_.0-9a-zA-Z]+' ,
errorMessage : 'Not a valid Github Repository Name' ,
} ,
} ,
] ,
url : '=https://github.com/{{$parameter["owner"]}}/{{$value}}' ,
} ,
] ,
2019-06-23 03:35:23 -07:00
displayOptions : {
hide : {
2022-05-31 00:11:50 -07:00
resource : [ 'user' , 'organization' ] ,
operation : [ 'getRepositories' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
} ,
// ----------------------------------
2019-07-14 07:50:26 -07:00
// file
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// ----------------------------------
// file:create/delete/edit/get
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
displayName : 'File Path' ,
name : 'filePath' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
2022-02-04 11:18:30 -08:00
hide : {
2022-05-31 00:11:50 -07:00
operation : [ 'list' ] ,
2022-02-04 11:18:30 -08:00
} ,
2019-06-23 03:35:23 -07:00
} ,
placeholder : 'docs/README.md' ,
description : 'The file path of the file. Has to contain the full path.' ,
} ,
2022-02-04 11:18:30 -08:00
// ----------------------------------
// file:list
// ----------------------------------
{
displayName : 'Path' ,
name : 'filePath' ,
type : 'string' ,
default : '' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'file' ] ,
operation : [ 'list' ] ,
2022-02-04 11:18:30 -08:00
} ,
} ,
placeholder : 'docs/' ,
2022-05-06 14:01:25 -07:00
description : 'The path of the folder to list' ,
2022-02-04 11:18:30 -08:00
} ,
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// file:create/edit
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
2024-01-03 03:08:16 -08:00
displayName : 'Binary File' ,
2019-06-23 03:35:23 -07:00
name : 'binaryData' ,
type : 'boolean' ,
default : false ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' , 'edit' ] ,
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-06-20 07:54:01 -07:00
description : 'Whether the data to upload should be taken from binary field' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'File Content' ,
name : 'fileContent' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
binaryData : [ false ] ,
operation : [ 'create' , 'edit' ] ,
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
placeholder : '' ,
2022-05-06 14:01:25 -07:00
description : 'The text content of the file' ,
2019-06-23 03:35:23 -07:00
} ,
{
2024-01-03 03:08:16 -08:00
displayName : 'Input Binary Field' ,
2019-06-23 03:35:23 -07:00
name : 'binaryPropertyName' ,
type : 'string' ,
default : 'data' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
binaryData : [ true ] ,
operation : [ 'create' , 'edit' ] ,
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
placeholder : '' ,
2024-01-03 03:08:16 -08:00
hint : 'The name of the input binary field containing the file to be written' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Commit Message' ,
name : 'commitMessage' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' , 'delete' , 'edit' ] ,
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
} ,
{
displayName : 'Additional Parameters' ,
name : 'additionalParameters' ,
placeholder : 'Add Parameter' ,
2022-05-06 14:01:25 -07:00
description : 'Additional fields to add' ,
2019-06-23 03:35:23 -07:00
type : 'fixedCollection' ,
default : { } ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' , 'delete' , 'edit' ] ,
resource : [ 'file' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
options : [
{
name : 'author' ,
displayName : 'Author' ,
values : [
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the author of the commit' ,
2019-06-23 03:35:23 -07:00
} ,
{
2020-07-07 02:31:05 -07:00
displayName : 'Email' ,
2019-06-23 03:35:23 -07:00
name : 'email' ,
type : 'string' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2019-06-23 03:35:23 -07:00
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The email of the author of the commit' ,
2019-06-23 03:35:23 -07:00
} ,
2020-10-22 06:46:03 -07:00
] ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'branch' ,
displayName : 'Branch' ,
values : [
{
displayName : 'Branch' ,
name : 'branch' ,
type : 'string' ,
default : '' ,
2022-05-31 00:11:50 -07:00
description :
'The branch to commit to. If not set the repository’ s default branch (usually master) is used.' ,
2019-06-23 03:35:23 -07:00
} ,
2020-10-22 06:46:03 -07:00
] ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'committer' ,
displayName : 'Committer' ,
values : [
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the committer of the commit' ,
2019-06-23 03:35:23 -07:00
} ,
{
2020-07-07 02:31:05 -07:00
displayName : 'Email' ,
2019-06-23 03:35:23 -07:00
name : 'email' ,
type : 'string' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2019-06-23 03:35:23 -07:00
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The email of the committer of the commit' ,
2019-06-23 03:35:23 -07:00
} ,
2020-10-22 06:46:03 -07:00
] ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
2019-07-14 07:50:26 -07:00
// ----------------------------------
// file:get
// ----------------------------------
{
displayName : 'As Binary Property' ,
name : 'asBinaryProperty' ,
type : 'boolean' ,
default : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'get' ] ,
resource : [ 'file' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
2022-05-31 00:11:50 -07:00
description :
2022-06-20 07:54:01 -07:00
'Whether to set the data of the file as binary property instead of returning the raw API response' ,
2019-07-14 07:50:26 -07:00
} ,
{
2024-01-03 03:08:16 -08:00
displayName : 'Put Output File in Field' ,
2019-07-14 07:50:26 -07:00
name : 'binaryPropertyName' ,
type : 'string' ,
default : 'data' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
asBinaryProperty : [ true ] ,
operation : [ 'get' ] ,
resource : [ 'file' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
placeholder : '' ,
2024-01-03 03:08:16 -08:00
hint : 'The name of the output binary field to put the file in' ,
2019-07-14 07:50:26 -07:00
} ,
2022-02-12 09:36:57 -08:00
{
displayName : 'Additional Parameters' ,
name : 'additionalParameters' ,
placeholder : 'Add Parameter' ,
2022-05-06 14:01:25 -07:00
description : 'Additional fields to add' ,
2022-02-12 09:36:57 -08:00
type : 'collection' ,
default : { } ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'get' ] ,
resource : [ 'file' ] ,
2022-02-12 09:36:57 -08:00
} ,
} ,
options : [
{
displayName : 'Reference' ,
name : 'reference' ,
type : 'string' ,
default : '' ,
placeholder : 'master' ,
2022-05-31 00:11:50 -07:00
description :
'The name of the commit/branch/tag. Default: the repository’ s default branch (usually master).' ,
2022-02-13 00:42:51 -08:00
} ,
2022-02-12 09:36:57 -08:00
] ,
} ,
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// issue
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// ----------------------------------
// issue:create
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The title of the issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
rows : 5 ,
} ,
default : '' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The body of the issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Labels' ,
name : 'labels' ,
type : 'collection' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Label' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-31 00:11:50 -07:00
default : { label : '' } ,
2019-06-23 03:35:23 -07:00
options : [
{
displayName : 'Label' ,
name : 'label' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Label to add to issue' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
{
displayName : 'Assignees' ,
name : 'assignees' ,
type : 'collection' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Assignee' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-31 00:11:50 -07:00
default : { assignee : '' } ,
2019-06-23 03:35:23 -07:00
options : [
{
displayName : 'Assignee' ,
name : 'assignee' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'User to assign issue too' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
// ----------------------------------
2019-07-14 07:50:26 -07:00
// issue:createComment
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
displayName : 'Issue Number' ,
name : 'issueNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'createComment' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the issue on which to create the comment on' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
rows : 5 ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'createComment' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The body of the comment' ,
2019-06-23 03:35:23 -07:00
} ,
// ----------------------------------
2019-07-14 07:50:26 -07:00
// issue:edit
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
displayName : 'Issue Number' ,
name : 'issueNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'edit' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the issue edit' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Edit Fields' ,
name : 'editFields' ,
type : 'collection' ,
typeOptions : {
multipleValueButtonText : 'Add Field' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'edit' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Title' ,
name : 'title' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The title of the issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
rows : 5 ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The body of the issue' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'State' ,
name : 'state' ,
type : 'options' ,
options : [
{
name : 'Closed' ,
value : 'closed' ,
2022-05-06 14:01:25 -07:00
description : 'Set the state to "closed"' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Open' ,
value : 'open' ,
2022-05-06 14:01:25 -07:00
description : 'Set the state to "open"' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
default : 'open' ,
2022-05-06 14:01:25 -07:00
description : 'The state to set' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Labels' ,
name : 'labels' ,
type : 'collection' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Label' ,
} ,
2022-05-31 00:11:50 -07:00
default : { label : '' } ,
2019-06-23 03:35:23 -07:00
options : [
{
displayName : 'Label' ,
name : 'label' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Label to add to issue' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
{
displayName : 'Assignees' ,
name : 'assignees' ,
type : 'collection' ,
typeOptions : {
multipleValues : true ,
multipleValueButtonText : 'Add Assignee' ,
} ,
2022-05-31 00:11:50 -07:00
default : { assignee : '' } ,
2019-06-23 03:35:23 -07:00
options : [
{
displayName : 'Assignees' ,
name : 'assignee' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'User to assign issue to' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
] ,
} ,
// ----------------------------------
2019-07-14 07:50:26 -07:00
// issue:get
2019-06-23 03:35:23 -07:00
// ----------------------------------
{
2019-07-14 07:50:26 -07:00
displayName : 'Issue Number' ,
name : 'issueNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
2019-06-23 03:35:23 -07:00
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'get' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the issue get data of' ,
2019-06-23 03:35:23 -07:00
} ,
2019-07-14 07:50:26 -07:00
// ----------------------------------
// issue:lock
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
displayName : 'Issue Number' ,
name : 'issueNumber' ,
type : 'number' ,
default : 0 ,
2019-06-23 03:35:23 -07:00
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'lock' ] ,
resource : [ 'issue' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the issue to lock' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Lock Reason' ,
name : 'lockReason' ,
type : 'options' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'lock' ] ,
resource : [ 'issue' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
options : [
{
name : 'Off-Topic' ,
value : 'off-topic' ,
description : 'The issue is Off-Topic' ,
} ,
{
name : 'Too Heated' ,
value : 'too heated' ,
description : 'The discussion is too heated' ,
} ,
{
name : 'Resolved' ,
value : 'resolved' ,
description : 'The issue got resolved' ,
} ,
{
name : 'Spam' ,
value : 'spam' ,
description : 'The issue is spam' ,
} ,
] ,
default : 'resolved' ,
2022-05-06 14:01:25 -07:00
description : 'The reason to lock the issue' ,
2019-06-23 03:35:23 -07:00
} ,
// ----------------------------------
2019-07-14 07:50:26 -07:00
// release
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// ----------------------------------
// release:create
// ----------------------------------
2019-06-23 03:35:23 -07:00
{
2019-07-14 07:50:26 -07:00
displayName : 'Tag' ,
name : 'releaseTag' ,
type : 'string' ,
default : '' ,
2019-06-23 03:35:23 -07:00
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'release' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The tag of the release' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
typeOptions : {
multipleValueButtonText : 'Add Field' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'release' ] ,
2019-07-14 07:50:26 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the issue' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
rows : 5 ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The body of the release' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Draft' ,
name : 'draft' ,
type : 'boolean' ,
default : false ,
2022-05-31 00:11:50 -07:00
description :
2022-06-20 07:54:01 -07:00
'Whether to create a draft (unpublished) release, "false" to create a published one' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Prerelease' ,
name : 'prerelease' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description : 'Whether to point out that the release is non-production ready' ,
2019-07-14 07:50:26 -07:00
} ,
{
displayName : 'Target Commitish' ,
name : 'target_commitish' ,
type : 'string' ,
default : '' ,
2022-05-31 00:11:50 -07:00
description :
2022-08-17 08:50:24 -07:00
"Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master)." ,
2019-07-14 07:50:26 -07:00
} ,
] ,
2019-06-23 03:35:23 -07:00
} ,
2021-04-09 22:54:05 -07:00
// ----------------------------------
// release:get/delete/update
// ----------------------------------
{
displayName : 'Release ID' ,
name : 'release_id' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'release' ] ,
operation : [ 'get' , 'delete' , 'update' ] ,
2021-04-09 22:54:05 -07:00
} ,
} ,
} ,
// ----------------------------------
// release:update
// ----------------------------------
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
type : 'collection' ,
typeOptions : {
multipleValueButtonText : 'Add Field' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'update' ] ,
resource : [ 'release' ] ,
2021-04-09 22:54:05 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
typeOptions : {
rows : 5 ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The body of the release' ,
2021-04-09 22:54:05 -07:00
} ,
{
displayName : 'Draft' ,
name : 'draft' ,
type : 'boolean' ,
default : false ,
2022-05-31 00:11:50 -07:00
description :
2022-06-20 07:54:01 -07:00
'Whether to create a draft (unpublished) release, "false" to create a published one' ,
2021-04-09 22:54:05 -07:00
} ,
2021-04-09 22:54:27 -07:00
{
displayName : 'Name' ,
name : 'name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the release' ,
2021-04-09 22:54:27 -07:00
} ,
2021-04-09 22:54:05 -07:00
{
displayName : 'Prerelease' ,
name : 'prerelease' ,
type : 'boolean' ,
default : false ,
2022-08-17 08:50:24 -07:00
description : 'Whether to point out that the release is non-production ready' ,
2021-04-09 22:54:05 -07:00
} ,
{
displayName : 'Tag Name' ,
name : 'tag_name' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The name of the tag' ,
2021-04-09 22:54:05 -07:00
} ,
{
displayName : 'Target Commitish' ,
name : 'target_commitish' ,
type : 'string' ,
default : '' ,
2022-05-31 00:11:50 -07:00
description :
2022-08-17 08:50:24 -07:00
"Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch(usually master)." ,
2021-04-09 22:54:05 -07:00
} ,
] ,
} ,
// ----------------------------------
// release:getAll
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'release' ] ,
operation : [ 'getAll' ] ,
2021-04-09 22:54:05 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-04-09 22:54:05 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'release' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-04-09 22:54:05 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-04-09 22:54:05 -07:00
} ,
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// repository
2019-06-23 03:35:23 -07:00
// ----------------------------------
2019-07-14 07:50:26 -07:00
// ----------------------------------
// repository:getIssues
// ----------------------------------
2021-03-20 13:18:47 -07:00
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'repository' ] ,
operation : [ 'getIssues' ] ,
2021-03-20 13:18:47 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-03-20 13:18:47 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'repository' ] ,
operation : [ 'getIssues' ] ,
returnAll : [ false ] ,
2021-03-20 13:18:47 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-03-20 13:18:47 -07:00
} ,
2019-06-23 03:35:23 -07:00
{
displayName : 'Filters' ,
name : 'getRepositoryIssuesFilters' ,
type : 'collection' ,
typeOptions : {
multipleValueButtonText : 'Add Filter' ,
} ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'getIssues' ] ,
resource : [ 'repository' ] ,
2019-06-23 03:35:23 -07:00
} ,
} ,
default : { } ,
options : [
{
displayName : 'Assignee' ,
name : 'assignee' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Return only issues which are assigned to a specific user' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Creator' ,
name : 'creator' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Return only issues which were created by a specific user' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Mentioned' ,
name : 'mentioned' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Return only issues in which a specific user was mentioned' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Labels' ,
name : 'labels' ,
type : 'string' ,
default : '' ,
2022-05-31 00:11:50 -07:00
description :
'Return only issues with the given labels. Multiple lables can be separated by comma.' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Updated Since' ,
name : 'since' ,
type : 'dateTime' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'Return only issues updated at or after this time' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'State' ,
name : 'state' ,
type : 'options' ,
options : [
{
name : 'All' ,
value : 'all' ,
2022-05-06 14:01:25 -07:00
description : 'Returns issues with any state' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Closed' ,
value : 'closed' ,
2022-05-06 14:01:25 -07:00
description : 'Return issues with "closed" state' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Open' ,
value : 'open' ,
2022-05-06 14:01:25 -07:00
description : 'Return issues with "open" state' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
default : 'open' ,
2022-05-06 14:01:25 -07:00
description : 'The state to set' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Sort' ,
name : 'sort' ,
type : 'options' ,
options : [
{
name : 'Created' ,
value : 'created' ,
2022-05-06 14:01:25 -07:00
description : 'Sort by created date' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Updated' ,
value : 'updated' ,
2022-05-06 14:01:25 -07:00
description : 'Sort by updated date' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Comments' ,
value : 'comments' ,
2022-05-06 14:01:25 -07:00
description : 'Sort by comments' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
default : 'created' ,
2022-05-06 14:01:25 -07:00
description : 'The order the issues should be returned in' ,
2019-06-23 03:35:23 -07:00
} ,
{
displayName : 'Direction' ,
name : 'direction' ,
type : 'options' ,
options : [
{
name : 'Ascending' ,
value : 'asc' ,
2022-05-06 14:01:25 -07:00
description : 'Sort in ascending order' ,
2019-06-23 03:35:23 -07:00
} ,
{
name : 'Descending' ,
value : 'desc' ,
2022-05-06 14:01:25 -07:00
description : 'Sort in descending order' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
default : 'desc' ,
2022-05-06 14:01:25 -07:00
description : 'The sort order' ,
2019-06-23 03:35:23 -07:00
} ,
] ,
} ,
2021-01-19 23:33:17 -08:00
// ----------------------------------
// rerview
// ----------------------------------
// ----------------------------------
// review:getAll
// ----------------------------------
{
displayName : 'PR Number' ,
name : 'pullRequestNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'get' , 'update' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the pull request' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Review ID' ,
name : 'reviewId' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'get' , 'update' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'ID of the review' ,
2021-01-19 23:33:17 -08:00
} ,
// ----------------------------------
// review:getAll
// ----------------------------------
{
displayName : 'PR Number' ,
name : 'pullRequestNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'getAll' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the pull request' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'review' ] ,
operation : [ 'getAll' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'review' ] ,
operation : [ 'getAll' ] ,
returnAll : [ false ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-01-19 23:33:17 -08:00
} ,
// ----------------------------------
// review:create
// ----------------------------------
{
displayName : 'PR Number' ,
name : 'pullRequestNumber' ,
type : 'number' ,
default : 0 ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The number of the pull request to review' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Event' ,
name : 'event' ,
type : 'options' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
options : [
{
name : 'Approve' ,
value : 'approve' ,
2022-05-06 14:01:25 -07:00
description : 'Approve the pull request' ,
2021-01-19 23:33:17 -08:00
} ,
{
name : 'Request Change' ,
value : 'requestChanges' ,
2022-05-06 14:01:25 -07:00
description : 'Request code changes' ,
2021-01-19 23:33:17 -08:00
} ,
{
name : 'Comment' ,
value : 'comment' ,
2022-05-06 14:01:25 -07:00
description : 'Add a comment without approval or change requests' ,
2021-01-19 23:33:17 -08:00
} ,
{
name : 'Pending' ,
value : 'pending' ,
2022-05-06 14:01:25 -07:00
description : 'You will need to submit the pull request review when you are ready' ,
2021-01-19 23:33:17 -08:00
} ,
] ,
default : 'approve' ,
2022-05-06 14:01:25 -07:00
description : 'The review action you want to perform' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'review' ] ,
event : [ 'requestChanges' , 'comment' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The body of the review (required for events Request Changes or Comment)' ,
2021-01-19 23:33:17 -08:00
} ,
{
displayName : 'Additional Fields' ,
name : 'additionalFields' ,
placeholder : 'Add Field' ,
type : 'collection' ,
default : { } ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'create' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
options : [
{
displayName : 'Commit ID' ,
name : 'commitId' ,
type : 'string' ,
default : '' ,
2022-05-06 14:01:25 -07:00
description : 'The SHA of the commit that needs a review, if different from the latest' ,
2021-01-19 23:33:17 -08:00
} ,
] ,
} ,
// ----------------------------------
// review:update
// ----------------------------------
{
displayName : 'Body' ,
name : 'body' ,
type : 'string' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'update' ] ,
resource : [ 'review' ] ,
2021-01-19 23:33:17 -08:00
} ,
} ,
default : '' ,
description : 'The body of the review' ,
} ,
2021-01-23 04:11:00 -08:00
// ----------------------------------
2021-03-20 13:18:47 -07:00
// user:getRepositories
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'user' ] ,
operation : [ 'getRepositories' ] ,
2021-03-20 13:18:47 -07:00
} ,
} ,
default : false ,
2022-05-06 14:01:25 -07:00
description : 'Whether to return all results or only up to a given limit' ,
2021-03-20 13:18:47 -07:00
} ,
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
resource : [ 'user' ] ,
operation : [ 'getRepositories' ] ,
returnAll : [ false ] ,
2021-03-20 13:18:47 -07:00
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
2022-05-06 14:01:25 -07:00
description : 'Max number of results to return' ,
2021-03-20 13:18:47 -07:00
} ,
2022-05-03 03:59:00 -07:00
2021-03-20 13:18:47 -07:00
// ----------------------------------
2021-01-23 04:11:00 -08:00
// user:invite
// ----------------------------------
{
displayName : 'Organization' ,
name : 'organization' ,
type : 'string' ,
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'invite' ] ,
resource : [ 'user' ] ,
2021-01-23 04:11:00 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The GitHub organization that the user is being invited to' ,
2021-01-23 04:11:00 -08:00
} ,
{
displayName : 'Email' ,
name : 'email' ,
type : 'string' ,
2022-06-20 07:54:01 -07:00
placeholder : 'name@email.com' ,
2021-01-23 04:11:00 -08:00
default : '' ,
required : true ,
displayOptions : {
show : {
2022-05-31 00:11:50 -07:00
operation : [ 'invite' ] ,
resource : [ 'user' ] ,
2021-01-23 04:11:00 -08:00
} ,
} ,
2022-05-06 14:01:25 -07:00
description : 'The email address of the invited user' ,
2021-01-23 04:11:00 -08:00
} ,
2022-05-31 00:11:50 -07:00
// ----------------------------------
// organization:getRepositories
// ----------------------------------
{
displayName : 'Return All' ,
name : 'returnAll' ,
type : 'boolean' ,
displayOptions : {
show : {
resource : [ 'organization' ] ,
operation : [ 'getRepositories' ] ,
} ,
} ,
default : false ,
description : 'Whether to return all results or only up to a given limit' ,
2021-10-20 20:35:51 -07:00
} ,
2022-05-31 00:11:50 -07:00
{
displayName : 'Limit' ,
name : 'limit' ,
type : 'number' ,
displayOptions : {
show : {
resource : [ 'organization' ] ,
operation : [ 'getRepositories' ] ,
returnAll : [ false ] ,
} ,
} ,
typeOptions : {
minValue : 1 ,
maxValue : 100 ,
} ,
default : 50 ,
description : 'Max number of results to return' ,
} ,
2019-06-23 03:35:23 -07:00
] ,
2021-10-20 20:35:51 -07:00
} ;
2019-06-23 03:35:23 -07:00
2023-02-16 03:54:42 -08:00
methods = {
listSearch : {
getUsers ,
getRepositories ,
} ,
} ;
2019-06-23 03:35:23 -07:00
async execute ( this : IExecuteFunctions ) : Promise < INodeExecutionData [ ] [ ] > {
const items = this . getInputData ( ) ;
2022-08-30 08:55:33 -07:00
const returnData : INodeExecutionData [ ] = [ ] ;
2019-06-23 03:35:23 -07:00
2021-01-19 23:33:17 -08:00
let returnAll = false ;
let responseData ;
2019-06-23 03:35:23 -07:00
// Operations which overwrite the returned data
const overwriteDataOperations = [
2019-07-14 07:50:26 -07:00
'file:create' ,
'file:delete' ,
'file:edit' ,
'file:get' ,
'issue:create' ,
'issue:createComment' ,
'issue:edit' ,
'issue:get' ,
'release:create' ,
2021-04-09 22:54:05 -07:00
'release:delete' ,
'release:get' ,
'release:update' ,
2019-09-11 14:46:17 -07:00
'repository:get' ,
2019-07-14 07:50:26 -07:00
'repository:getLicense' ,
'repository:getProfile' ,
2021-01-19 23:33:17 -08:00
'review:create' ,
'review:get' ,
'review:update' ,
2021-01-23 04:11:00 -08:00
'user:invite' ,
2019-06-23 03:35:23 -07:00
] ;
// Operations which overwrite the returned data and return arrays
// and has so to be merged with the data of other items
const overwriteDataOperationsArray = [
2022-02-04 11:18:30 -08:00
'file:list' ,
2019-07-14 07:50:26 -07:00
'repository:getIssues' ,
'repository:listPopularPaths' ,
'repository:listReferrers' ,
'user:getRepositories' ,
2021-04-09 22:54:05 -07:00
'release:getAll' ,
2021-01-19 23:33:17 -08:00
'review:getAll' ,
2022-05-05 08:31:26 -07:00
'organization:getRepositories' ,
2019-06-23 03:35:23 -07:00
] ;
// For Post
let body : IDataObject ;
// For Query string
let qs : IDataObject ;
2024-02-14 07:29:09 -08:00
let requestMethod : IHttpRequestMethods ;
2019-06-23 03:35:23 -07:00
let endpoint : string ;
2022-12-02 03:53:59 -08:00
const operation = this . getNodeParameter ( 'operation' , 0 ) ;
const resource = this . getNodeParameter ( 'resource' , 0 ) ;
2019-07-14 07:50:26 -07:00
const fullOperation = ` ${ resource } : ${ operation } ` ;
2019-06-23 03:35:23 -07:00
for ( let i = 0 ; i < items . length ; i ++ ) {
2021-07-19 23:58:54 -07:00
try {
// Reset all values
requestMethod = 'GET' ;
endpoint = '' ;
body = { } ;
qs = { } ;
let owner = '' ;
if ( fullOperation !== 'user:invite' ) {
// Request the parameters which almost all operations need
2023-02-16 03:54:42 -08:00
owner = this . getNodeParameter ( 'owner' , i , '' , { extractValue : true } ) as string ;
2021-07-19 23:58:54 -07:00
}
2021-01-23 04:11:00 -08:00
2021-07-19 23:58:54 -07:00
let repository = '' ;
2022-05-31 00:11:50 -07:00
if (
fullOperation !== 'user:getRepositories' &&
fullOperation !== 'user:invite' &&
fullOperation !== 'organization:getRepositories'
) {
2023-02-16 03:54:42 -08:00
repository = this . getNodeParameter ( 'repository' , i , '' , { extractValue : true } ) as string ;
2021-07-19 23:58:54 -07:00
}
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
if ( resource === 'file' ) {
if ( [ 'create' , 'edit' ] . includes ( operation ) ) {
// ----------------------------------
// create/edit
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'PUT' ;
2019-06-23 03:35:23 -07:00
2023-01-06 06:09:32 -08:00
const filePath = this . getNodeParameter ( 'filePath' , i ) ;
2019-06-23 03:35:23 -07:00
2022-05-31 00:11:50 -07:00
const additionalParameters = this . getNodeParameter (
'additionalParameters' ,
i ,
{ } ,
) as IDataObject ;
2021-07-19 23:58:54 -07:00
if ( additionalParameters . author ) {
body . author = additionalParameters . author ;
}
if ( additionalParameters . committer ) {
body . committer = additionalParameters . committer ;
}
2022-05-31 00:11:50 -07:00
if (
additionalParameters . branch &&
( additionalParameters . branch as IDataObject ) . branch
) {
2021-07-19 23:58:54 -07:00
body . branch = ( additionalParameters . branch as IDataObject ) . branch ;
}
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
if ( operation === 'edit' ) {
// If the file should be updated the request has to contain the SHA
// of the file which gets replaced.
2022-05-31 00:11:50 -07:00
body . sha = await getFileSha . call (
this ,
owner ,
repository ,
filePath ,
body . branch as string | undefined ,
) ;
2021-07-19 23:58:54 -07:00
}
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
body . message = this . getNodeParameter ( 'commitMessage' , i ) as string ;
2019-07-14 07:50:26 -07:00
2022-12-02 12:54:28 -08:00
if ( this . getNodeParameter ( 'binaryData' , i ) ) {
2021-07-19 23:58:54 -07:00
// Currently internally n8n uses base64 and also Github expects it base64 encoded.
// If that ever changes the data has to get converted here.
2023-03-06 08:33:32 -08:00
const binaryPropertyName = this . getNodeParameter ( 'binaryPropertyName' , i ) ;
const binaryData = this . helpers . assertBinaryData ( i , binaryPropertyName ) ;
// TODO: Does this work with filesystem mode
body . content = binaryData . data ;
2021-07-19 23:58:54 -07:00
} else {
// Is text file
// body.content = Buffer.from(this.getNodeParameter('fileContent', i) as string, 'base64');
2022-05-31 00:11:50 -07:00
body . content = Buffer . from (
this . getNodeParameter ( 'fileContent' , i ) as string ,
) . toString ( 'base64' ) ;
2021-07-19 23:58:54 -07:00
}
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /contents/ ${ encodeURI ( filePath ) } ` ;
} else if ( operation === 'delete' ) {
// ----------------------------------
// delete
// ----------------------------------
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'DELETE' ;
2019-06-23 03:35:23 -07:00
2022-05-31 00:11:50 -07:00
const additionalParameters = this . getNodeParameter (
'additionalParameters' ,
i ,
{ } ,
) as IDataObject ;
2021-07-19 23:58:54 -07:00
if ( additionalParameters . author ) {
body . author = additionalParameters . author ;
}
if ( additionalParameters . committer ) {
body . committer = additionalParameters . committer ;
}
2022-05-31 00:11:50 -07:00
if (
additionalParameters . branch &&
( additionalParameters . branch as IDataObject ) . branch
) {
2021-07-19 23:58:54 -07:00
body . branch = ( additionalParameters . branch as IDataObject ) . branch ;
}
2019-06-23 03:35:23 -07:00
2023-01-06 06:09:32 -08:00
const filePath = this . getNodeParameter ( 'filePath' , i ) ;
2021-07-19 23:58:54 -07:00
body . message = this . getNodeParameter ( 'commitMessage' , i ) as string ;
2019-07-14 07:50:26 -07:00
2022-05-31 00:11:50 -07:00
body . sha = await getFileSha . call (
this ,
owner ,
repository ,
filePath ,
body . branch as string | undefined ,
) ;
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /contents/ ${ encodeURI ( filePath ) } ` ;
2022-03-20 02:24:04 -07:00
} else if ( operation === 'get' ) {
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-07-14 07:50:26 -07:00
2023-01-06 06:09:32 -08:00
const filePath = this . getNodeParameter ( 'filePath' , i ) ;
2022-05-31 00:11:50 -07:00
const additionalParameters = this . getNodeParameter (
'additionalParameters' ,
i ,
) as IDataObject ;
2019-07-14 07:50:26 -07:00
2022-02-12 09:36:57 -08:00
if ( additionalParameters . reference ) {
qs . ref = additionalParameters . reference ;
}
2022-03-20 02:24:04 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /contents/ ${ encodeURI ( filePath ) } ` ;
} else if ( operation === 'list' ) {
requestMethod = 'GET' ;
2023-01-06 06:09:32 -08:00
const filePath = this . getNodeParameter ( 'filePath' , i ) ;
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /contents/ ${ encodeURI ( filePath ) } ` ;
}
} else if ( resource === 'issue' ) {
if ( operation === 'create' ) {
// ----------------------------------
// create
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
body . title = this . getNodeParameter ( 'title' , i ) as string ;
body . body = this . getNodeParameter ( 'body' , i ) as string ;
const labels = this . getNodeParameter ( 'labels' , i ) as IDataObject [ ] ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const assignees = this . getNodeParameter ( 'assignees' , i ) as IDataObject [ ] ;
2019-06-23 03:35:23 -07:00
2022-12-02 12:54:28 -08:00
body . labels = labels . map ( ( data ) = > data . label ) ;
body . assignees = assignees . map ( ( data ) = > data . assignee ) ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues ` ;
} else if ( operation === 'createComment' ) {
// ----------------------------------
// createComment
// ----------------------------------
requestMethod = 'POST' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const issueNumber = this . getNodeParameter ( 'issueNumber' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
body . body = this . getNodeParameter ( 'body' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues/ ${ issueNumber } /comments ` ;
} else if ( operation === 'edit' ) {
// ----------------------------------
// edit
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'PATCH' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const issueNumber = this . getNodeParameter ( 'issueNumber' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
body = this . getNodeParameter ( 'editFields' , i , { } ) as IDataObject ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
if ( body . labels !== undefined ) {
2022-12-02 12:54:28 -08:00
body . labels = ( body . labels as IDataObject [ ] ) . map ( ( data ) = > data . label ) ;
2021-07-19 23:58:54 -07:00
}
if ( body . assignees !== undefined ) {
2022-12-02 12:54:28 -08:00
body . assignees = ( body . assignees as IDataObject [ ] ) . map ( ( data ) = > data . assignee ) ;
2021-07-19 23:58:54 -07:00
}
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues/ ${ issueNumber } ` ;
} else if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const issueNumber = this . getNodeParameter ( 'issueNumber' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues/ ${ issueNumber } ` ;
} else if ( operation === 'lock' ) {
// ----------------------------------
// lock
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'PUT' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const issueNumber = this . getNodeParameter ( 'issueNumber' , i ) as string ;
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
qs . lock_reason = this . getNodeParameter ( 'lockReason' , i ) as string ;
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues/ ${ issueNumber } /lock ` ;
}
} else if ( resource === 'release' ) {
if ( operation === 'create' ) {
// ----------------------------------
// create
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
2019-06-23 03:35:23 -07:00
2022-12-02 12:54:28 -08:00
body = this . getNodeParameter ( 'additionalFields' , i , { } ) ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
body . tag_name = this . getNodeParameter ( 'releaseTag' , i ) as string ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /releases ` ;
}
if ( operation === 'delete' ) {
// ----------------------------------
// delete
// ----------------------------------
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'DELETE' ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
const releaseId = this . getNodeParameter ( 'release_id' , i ) as string ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /releases/ ${ releaseId } ` ;
}
if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
const releaseId = this . getNodeParameter ( 'release_id' , i ) as string ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /releases/ ${ releaseId } ` ;
}
if ( operation === 'getAll' ) {
// ----------------------------------
// getAll
// ----------------------------------
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /releases ` ;
2021-04-09 22:54:05 -07:00
2022-11-18 05:31:38 -08:00
returnAll = this . getNodeParameter ( 'returnAll' , 0 ) ;
2021-04-09 22:54:05 -07:00
2022-12-02 12:54:28 -08:00
if ( ! returnAll ) {
2022-11-18 06:26:22 -08:00
qs . per_page = this . getNodeParameter ( 'limit' , 0 ) ;
2021-07-19 23:58:54 -07:00
}
2021-04-09 22:54:05 -07:00
}
2021-07-19 23:58:54 -07:00
if ( operation === 'update' ) {
// ----------------------------------
// update
// ----------------------------------
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'PATCH' ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
const releaseId = this . getNodeParameter ( 'release_id' , i ) as string ;
2021-04-09 22:54:05 -07:00
2022-12-02 12:54:28 -08:00
body = this . getNodeParameter ( 'additionalFields' , i , { } ) ;
2021-04-09 22:54:05 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /releases/ ${ releaseId } ` ;
}
} else if ( resource === 'repository' ) {
if ( operation === 'listPopularPaths' ) {
// ----------------------------------
// listPopularPaths
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /traffic/popular/paths ` ;
} else if ( operation === 'listReferrers' ) {
// ----------------------------------
// listReferrers
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /traffic/popular/referrers ` ;
} else if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
2019-09-11 14:46:17 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-09-11 14:46:17 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } ` ;
} else if ( operation === 'getLicense' ) {
// ----------------------------------
// getLicense
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /license ` ;
} else if ( operation === 'getIssues' ) {
// ----------------------------------
// getIssues
// ----------------------------------
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
qs = this . getNodeParameter ( 'getRepositoryIssuesFilters' , i ) as IDataObject ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /issues ` ;
2021-03-20 13:18:47 -07:00
2022-11-18 05:31:38 -08:00
returnAll = this . getNodeParameter ( 'returnAll' , 0 ) ;
2021-03-20 13:18:47 -07:00
2022-12-02 12:54:28 -08:00
if ( ! returnAll ) {
2022-11-18 06:26:22 -08:00
qs . per_page = this . getNodeParameter ( 'limit' , 0 ) ;
2021-07-19 23:58:54 -07:00
}
2021-03-20 13:18:47 -07:00
}
2021-07-19 23:58:54 -07:00
} else if ( resource === 'review' ) {
if ( operation === 'get' ) {
// ----------------------------------
// get
// ----------------------------------
requestMethod = 'GET' ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
const reviewId = this . getNodeParameter ( 'reviewId' , i ) as string ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
const pullRequestNumber = this . getNodeParameter ( 'pullRequestNumber' , i ) as string ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /pulls/ ${ pullRequestNumber } /reviews/ ${ reviewId } ` ;
} else if ( operation === 'getAll' ) {
// ----------------------------------
// getAll
// ----------------------------------
requestMethod = 'GET' ;
2021-01-19 23:33:17 -08:00
2022-11-18 05:31:38 -08:00
returnAll = this . getNodeParameter ( 'returnAll' , 0 ) ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
const pullRequestNumber = this . getNodeParameter ( 'pullRequestNumber' , i ) as string ;
2021-01-19 23:33:17 -08:00
2022-12-02 12:54:28 -08:00
if ( ! returnAll ) {
2022-11-18 06:26:22 -08:00
qs . per_page = this . getNodeParameter ( 'limit' , 0 ) ;
2021-07-19 23:58:54 -07:00
}
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /pulls/ ${ pullRequestNumber } /reviews ` ;
} else if ( operation === 'create' ) {
// ----------------------------------
// create
// ----------------------------------
requestMethod = 'POST' ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
const pullRequestNumber = this . getNodeParameter ( 'pullRequestNumber' , i ) as string ;
2022-11-18 07:29:44 -08:00
const additionalFields = this . getNodeParameter ( 'additionalFields' , i ) ;
2021-07-19 23:58:54 -07:00
Object . assign ( body , additionalFields ) ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
body . event = snakeCase ( this . getNodeParameter ( 'event' , i ) as string ) . toUpperCase ( ) ;
if ( body . event === 'REQUEST_CHANGES' || body . event === 'COMMENT' ) {
body . body = this . getNodeParameter ( 'body' , i ) as string ;
}
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /pulls/ ${ pullRequestNumber } /reviews ` ;
} else if ( operation === 'update' ) {
// ----------------------------------
// update
// ----------------------------------
requestMethod = 'PUT' ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
const pullRequestNumber = this . getNodeParameter ( 'pullRequestNumber' , i ) as string ;
const reviewId = this . getNodeParameter ( 'reviewId' , i ) as string ;
2021-01-19 23:33:17 -08:00
2021-07-19 23:58:54 -07:00
body . body = this . getNodeParameter ( 'body' , i ) as string ;
2021-03-20 13:18:47 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /repos/ ${ owner } / ${ repository } /pulls/ ${ pullRequestNumber } /reviews/ ${ reviewId } ` ;
}
} else if ( resource === 'user' ) {
if ( operation === 'getRepositories' ) {
// ----------------------------------
// getRepositories
// ----------------------------------
2019-07-14 07:50:26 -07:00
2021-07-19 23:58:54 -07:00
requestMethod = 'GET' ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
endpoint = ` /users/ ${ owner } /repos ` ;
2021-01-23 04:11:00 -08:00
2022-11-18 05:31:38 -08:00
returnAll = this . getNodeParameter ( 'returnAll' , 0 ) ;
2021-03-20 13:18:47 -07:00
2022-12-02 12:54:28 -08:00
if ( ! returnAll ) {
2022-11-18 06:26:22 -08:00
qs . per_page = this . getNodeParameter ( 'limit' , 0 ) ;
2021-07-19 23:58:54 -07:00
}
} else if ( operation === 'invite' ) {
// ----------------------------------
// invite
// ----------------------------------
2021-01-23 04:11:00 -08:00
2021-07-19 23:58:54 -07:00
requestMethod = 'POST' ;
const org = this . getNodeParameter ( 'organization' , i ) as string ;
endpoint = ` /orgs/ ${ org } /invitations ` ;
body . email = this . getNodeParameter ( 'email' , i ) as string ;
}
2022-05-04 07:33:46 -07:00
} else if ( resource === 'organization' ) {
2022-05-05 08:31:26 -07:00
if ( operation === 'getRepositories' ) {
2022-05-04 07:33:46 -07:00
// ----------------------------------
// getRepositories
// ----------------------------------
requestMethod = 'GET' ;
endpoint = ` /orgs/ ${ owner } /repos ` ;
2022-11-18 05:31:38 -08:00
returnAll = this . getNodeParameter ( 'returnAll' , 0 ) ;
2021-07-19 23:58:54 -07:00
2022-12-02 12:54:28 -08:00
if ( ! returnAll ) {
2022-11-18 06:26:22 -08:00
qs . per_page = this . getNodeParameter ( 'limit' , 0 ) ;
2022-05-04 07:33:46 -07:00
}
2022-05-31 00:11:50 -07:00
}
2021-07-19 23:58:54 -07:00
} else {
2022-08-17 08:50:24 -07:00
throw new NodeOperationError ( this . getNode ( ) , ` The resource " ${ resource } " is not known! ` , {
itemIndex : i ,
} ) ;
2019-07-14 07:50:26 -07:00
}
2021-01-23 04:11:00 -08:00
2022-08-30 08:55:33 -07:00
const asBinaryProperty = this . getNodeParameter ( 'asBinaryProperty' , i , false ) as boolean ;
2022-12-02 12:54:28 -08:00
if ( returnAll ) {
2022-05-31 00:11:50 -07:00
responseData = await githubApiRequestAllItems . call (
this ,
requestMethod ,
endpoint ,
body ,
qs ,
) ;
2021-07-19 23:58:54 -07:00
} else {
responseData = await githubApiRequest . call ( this , requestMethod , endpoint , body , qs ) ;
}
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
if ( fullOperation === 'file:get' ) {
2022-12-02 12:54:28 -08:00
if ( asBinaryProperty ) {
2022-08-30 08:55:33 -07:00
if ( Array . isArray ( responseData ) && responseData . length > 1 ) {
2022-08-17 08:50:24 -07:00
throw new NodeOperationError ( this . getNode ( ) , 'File Path is a folder, not a file.' , {
itemIndex : i ,
} ) ;
2022-02-04 11:18:30 -08:00
}
2021-07-19 23:58:54 -07:00
// Add the returned data to the item as binary property
2023-01-06 06:09:32 -08:00
const binaryPropertyName = this . getNodeParameter ( 'binaryPropertyName' , i ) ;
2019-06-23 03:35:23 -07:00
2021-07-19 23:58:54 -07:00
const newItem : INodeExecutionData = {
json : items [ i ] . json ,
binary : { } ,
2024-01-02 21:06:41 -08:00
pairedItem : items [ i ] . pairedItem ,
2021-07-19 23:58:54 -07:00
} ;
2019-08-01 13:55:33 -07:00
2021-07-19 23:58:54 -07:00
if ( items [ i ] . binary !== undefined ) {
// Create a shallow copy of the binary data so that the old
// data references which do not get changed still stay behind
// but the incoming data does not get changed.
2022-08-30 08:55:33 -07:00
Object . assign ( newItem . binary as object , items [ i ] . binary ! ) ;
2021-07-19 23:58:54 -07:00
}
2022-09-03 04:35:44 -07:00
const { content , path } = responseData ;
2022-05-31 00:11:50 -07:00
newItem . binary ! [ binaryPropertyName ] = await this . helpers . prepareBinaryData (
2022-08-30 08:55:33 -07:00
Buffer . from ( content as string , 'base64' ) ,
path as string ,
2022-05-31 00:11:50 -07:00
) ;
2019-08-01 13:55:33 -07:00
2024-01-02 21:06:41 -08:00
returnData . push ( newItem ) ;
continue ;
2021-07-19 23:58:54 -07:00
}
}
2022-08-30 08:55:33 -07:00
2021-07-19 23:58:54 -07:00
if ( fullOperation === 'release:delete' ) {
responseData = { success : true } ;
}
2019-08-01 13:55:33 -07:00
2022-08-30 08:55:33 -07:00
if (
overwriteDataOperations . includes ( fullOperation ) ||
overwriteDataOperationsArray . includes ( fullOperation )
) {
const executionData = this . helpers . constructExecutionMetaData (
2023-02-27 19:39:43 -08:00
this . helpers . returnJsonArray ( responseData as IDataObject [ ] ) ,
2022-08-30 08:55:33 -07:00
{ itemData : { item : i } } ,
) ;
returnData . push ( . . . executionData ) ;
2019-06-23 03:35:23 -07:00
}
2021-07-19 23:58:54 -07:00
} catch ( error ) {
if ( this . continueOnFail ( ) ) {
2022-05-31 00:11:50 -07:00
if (
overwriteDataOperations . includes ( fullOperation ) ||
overwriteDataOperationsArray . includes ( fullOperation )
) {
2022-08-30 08:55:33 -07:00
const executionErrorData = this . helpers . constructExecutionMetaData (
[
{
json : {
error : error.message ,
} ,
} ,
] ,
{ itemData : { item : i } } ,
) ;
returnData . push ( . . . executionErrorData ) ;
2021-07-19 23:58:54 -07:00
} else {
items [ i ] . json = { error : error.message } ;
}
continue ;
}
throw error ;
2019-06-23 03:35:23 -07:00
}
}
2022-05-31 00:11:50 -07:00
if (
overwriteDataOperations . includes ( fullOperation ) ||
overwriteDataOperationsArray . includes ( fullOperation )
) {
2019-06-23 03:35:23 -07:00
// Return data gets replaced
2023-09-05 03:59:02 -07:00
return [ returnData ] ;
2019-06-23 03:35:23 -07:00
} else {
// For all other ones simply return the unchanged items
2022-08-30 08:55:33 -07:00
return [ items ] ;
2019-06-23 03:35:23 -07:00
}
}
}