GitHub WebHook call Action on another GitHub repository - github

Want to trigger a GitHub Action (Repository B) from another GitHub Repository (A) via WebHook.
So I try to configuring the WebHook on repository A but I can not specify the Authorization Header that is needed by GitHub Repository B.
Is this possible at all via WebHooks?
Both Repositories belong to the same Organization.

via WebHook
That means repo A WebHook URL is called, and your local endpoint (which listen to the wayhook payload) would need to receive a parameter representing the URL/name of repoB, which it then could curl -X POST in order to trigger its workflow (assuming you have the right token allowed to run API on repoB, in Authorization: bearer <token>).
Considering a webhook JSON payload for a push event include commit(s) message, I would push on repoA a commit with, in its message, the name or URL of repoB.
Your local webhook listener can then extract repoB, and tribber its workflow.

Related

OAuth Scope required for Creating Github pull requests with Personal Access Token

I need to create documentation giving instructions to generate a Personal Access Token that will only need to create Pull Requests on Github.
I've read the documentation describing the various OAuth scopes, but it is still not clear to me which OAuth scope(s) I need to select in order to be able create a Pull Request.
What OAuth scope(s) need to be selected for users to be able to create Pull Requests?
From https://docs.github.com/en/rest/reference/pulls#create-a-pull-request:
To open or update a pull request in a public repository, you must have write access to the head or the source branch. For organization-owned repositories, you must be a member of the organization that owns the repository to open or update a pull request.
The repos scope should be needed.
And, with the GitHub CLI gh v2.22.0 (Jan. 2023), you can search from within your local cloned GitHub repository:
See gh auth status --show-token: it will display the auth token you are using.

How gitub webhooks works?

How the github webhooks works, and how would it know which build needs to trigger based on the events.
I have an public git repository and in which have configured the jenkins webhooks which triggers build on the every push event.
Payload URL: http:///github-webhook/
Content Type: www-form-urlencoded
Event: Push
How the Payload URL identifies the right build job to trigger?
You can using "Generic Webhook Trigger" or "Trigger Builds Remotely" Plugin and specify token on your jenkins job. Pass your jenkins server url (with token you have specified) on github webhook payload url

how to trigger a jenkins pipeline stage when an authorized user make a comment on github pull request?

I am familiar with Jenkins Pull Request Builder and I had set up a freestyle job with it to build my project based on the comment that authorized user put. (For example test in prod) in the past.
Now I am trying to use a Jenkins 2.0 with github organization plugin for one of my project.
this is the scenario:
A User is making a PR to master(or some other sensitive branch)
A test is going to get run automatically.
After the test past, an authorized user needs to go to the PR and put a comment Deploy to test environment and then a jenkinsfile that was waiting for this input needs to get trigger.
I just dont know how to do the step 3. how do I make jenkins pipeline job listen for comments in github repo pull requests? the Jenkins documentation is not really clear about the input from user part.
I read this thread answer but the documentation about the Gates approval is really limited.
I know this is super late, but here's some info for future Googlers:
I have a Github webhook that sends the event to a Lambda function that will parse the event for a specific comment string, then create an HTTP POST request for the Jenkins job, which is configured to allow builds to be triggered remotely.
So: open PR > comment on PR 'Deploy to test environment' > webhook sends to AWS APIGateway > AWS SNS topic > AWS Lambda > parse the event for comment > If comment matches, create HTTP POST > Jenkins receives request and runs job
There's a lot of documentation on this, but none of it together, so here are the resources that I used:
Regarding allowing jobs to be triggered remotely:
https://wiki.jenkins-ci.org/display/JENKINS/Remote+access+API
Using Github to trigger Lambda function:
https://aws.amazon.com/blogs/compute/dynamic-github-actions-with-aws-lambda/
Github API. You will want to pay particular attention to the Issues API:
https://developer.github.com/webhooks/

No repository found for hub.topic - Scope issue?

I am trying to subscribe to changes in a particular repository but I'm getting a "No repository found for hub.topic".
Here's my request:
curl -u "user" -i https://api.github.com/hub -F "hub.mode=subscribe" -F "hub.topic=https://github.com/iOS-Goodies/iOS-Goodies/events/watch" -F "hub.callback=callback"
Given that this curl request follows Github's documentation guidelines and that it works for my own repositories, I assume this is a matter of scope.
Am I unable to subscribe to events on repositories I do not own?
Thanks
You have to be an administrator of the repository in order to perform that API request. The PubSubHubbub API follows the same permission rules as the Webhooks API: "The Repository Webhooks API allows repository admins to manage the post-receive hooks for a repository. Webhooks can be managed using the JSON HTTP API, or the PubSubHubbub API."

Passing custom variables/parameters to jenkins job by github pull requester builder comments

I have to pass few varibles to the jenkins job from the GITHUB pull request. I am using github pull request builder and is there any way i can pass some varible values to jenkins when I create a pull request?