You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by mr...@apache.org on 2021/05/21 14:11:14 UTC
[openwhisk-catalog] branch master updated: Enhance GitHub webhook
introducing allowing usage for GitHub Enterprise. (#321)
This is an automated email from the ASF dual-hosted git repository.
mrutkowski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-catalog.git
The following commit(s) were added to refs/heads/master by this push:
new 26fadd7 Enhance GitHub webhook introducing allowing usage for GitHub Enterprise. (#321)
26fadd7 is described below
commit 26fadd717c888d18a1ca315179c23c8a310d4375
Author: fribechi <fa...@it.ibm.com>
AuthorDate: Fri May 21 16:10:09 2021 +0200
Enhance GitHub webhook introducing allowing usage for GitHub Enterprise. (#321)
---
packages/github/README.md | 2 ++
packages/github/manifest.yaml | 9 ++++++++-
packages/github/webhook.js | 11 +++++++++--
3 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/packages/github/README.md b/packages/github/README.md
index b0b9ad7..9587f1c 100644
--- a/packages/github/README.md
+++ b/packages/github/README.md
@@ -38,6 +38,7 @@ The `/whisk.system/github/webhook` feed configures a service to fire a trigger w
- `repository`: The GitHub repository.
- `accessToken`: Your GitHub personal access token.
- `events`: The [GitHub event type](https://developer.github.com/v3/activity/events/types/) of interest.
+- `baseUrl`: The GitHub api endpoint. Default value is 'https://api.github.com'.
The following is an example of creating a trigger that will be fired each time that there is a new commit to a GitHub repository.
@@ -52,6 +53,7 @@ The following is an example of creating a trigger that will be fired each time t
```
wsk package bind /whisk.system/github myGit \
+ --param baseUrl https://github.myenterprise.com/api/v3 \
--param username myGitUser \
--param repository myGitRepo \
--param accessToken aaaaa1111a1a1a1a1a111111aaaaaa1111aa1a1a
diff --git a/packages/github/manifest.yaml b/packages/github/manifest.yaml
index 10377b4..022ace4 100644
--- a/packages/github/manifest.yaml
+++ b/packages/github/manifest.yaml
@@ -55,11 +55,18 @@ project:
"required": true,
"description": "A comma-separated list",
"doclink": "https://developer.github.com/webhooks/#events"
+ },
+ {
+ "name": "baseUrl",
+ "required": false,
+ "description": "GitHub API endpoint",
+ "doclink": "https://docs.github.com/en/enterprise-server@2.21/rest/reference/enterprise-admin#endpoint-urls"
}
]
sampleInput: {
"username": "myUserName",
"repository": "myRepository or myOrganization/myRepository",
"accessToken": "123ABCXYZ",
- "events": "push, delete, pull-request"
+ "events": "push, delete, pull-request",
+ "baseUrl": "https://github.myenterprise.com/api/v3"
}
diff --git a/packages/github/webhook.js b/packages/github/webhook.js
index 6ce156d..6e5563b 100644
--- a/packages/github/webhook.js
+++ b/packages/github/webhook.js
@@ -32,7 +32,14 @@ function main(params) {
var accessToken = params.accessToken;
var organization,
- repository;
+ repository,
+ baseUrl;
+
+ if (params.baseUrl) {
+ baseUrl = params.baseUrl;
+ } else {
+ baseUrl = 'https://api.github.com';
+ }
if (params.repository) {
var repoSegments = params.repository.split('/');
@@ -52,7 +59,7 @@ function main(params) {
var whiskCallbackUrl = urlHost.protocol + '//' + process.env.__OW_API_KEY + "@" + urlHost.host + '/api/v1/namespaces/' + encodeURIComponent(triggerName[1]) + '/triggers/' + encodeURIComponent(triggerName[2]);
// The URL to create the webhook on Github
- var registrationEndpoint = 'https://api.github.com/repos/' + (organization ? organization : username) + '/' + repository + '/hooks';
+ var registrationEndpoint = baseUrl +'/repos/' + (organization ? organization : username) + '/' + repository + '/hooks';
console.log("Using endpoint: " + registrationEndpoint);
if (lifecycleEvent === 'CREATE') {