Setup rules/alerts before raising a PR in Github - github

Basically whenever somebody raises a PR on my repository, I want to ensure that the person raising the PR has performed some actions (running a script etc.)
So is there a way to set up some rule or some alert so as to remind the person to perform that action before raising the PR.

You should use something called integration. Here you can see the GitHub Integrations Directory.
My favorite is Travis CI–you set it up using a .travis.yml file and then after the commits are pushed the tests are run and Travis sends the status response which will be visible to in the Pull request.
However, this can't stop the user to submit the pull request.
Like I mentioned, you cannot stop the user to open pull requests but you can tell him/her the steps how to contribute using the CONTRIBUTING.md in your project. Then when somebody opens a pull request or issue will see this alert:

Related

github actions main repository secret not picked up from pull request build

I'm building out one of my company project through Github actions, in which we are running the workflow from latest pull request raised. I have notice one thing, whenever it tries to execute the secret from main the repository, its gives error as bad credentials.
Same stage when I tried to run from main repository it works fine. Do We have given some permissions to pull request to call secret from main repository.
Any suggestions will help.
By default, pull-request builds don't get access to the secrets to prevent people from using the pull requests to exfiltrate your secrets through a change that reads the environment and sends the data somewhere else.
Due to the dangers inherent to automatic processing of PRs, GitHub’s standard pull_request workflow trigger by default prevents write permissions and secrets access to the target repository. However, in some scenarios such access is needed to properly process the PR. To this end the pull_request_target workflow trigger was introduced.
See here for additional details:
https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

Why is a check suite not being created for a forked PR?

I created a new GitHub App to perform check runs. I want it to be triggered on every PR. It is working great when I get a PR from a different branch in my repository. But, when someone forks my repo and makes a PR, my application's webhook never gets the check suite requested event which it uses to trigger a check run. Why? How can I change this?

How to auto merge pull request on github?

Is it possible to merge pull request automaticaly to master branch on github after success of travis test webhook?
You can use Mergify to do this.
It allows to configure rules and define criteria for your pull request to be automatically merged. In your case, setting something like "Travis check is OK and one reviewer approved the PR" would allow the PR to be automatically merged.
(Disclosure: I'm part of the Mergify team.)
You can most probably add an after_success action to your .travis.yml that would merge the PR using GitHub API. I do not know of any ready to use script for this, but there is no reason for it to be hard. Special care needed for authentication ...
GitHub recently shipped this auto-merge feature in beta. To use this, you can enable it in the repo settings. Just keep in mind you will need to add branch protection rules as well.
See the documentation for more info.
https://docs.github.com/en/free-pro-team#latest/github/collaborating-with-issues-and-pull-requests/automatically-merging-a-pull-request
I work on a project that requires pull requests to be up to date with the target branch, and also to have passed all the checks before merging.
This means we can often be waiting for checks to finish, only to find a new commit has been made to the target branch, which requires the pull request to be synchronised and the checks to run all over again. I wanted a simple app to merge the PR automatically once the checks are successful, so I created one.
Mergery is:
Free, including for private repositories.
Fast. It's event-driven, it doesn't run on a schedule.
Simple. No configuration required. Just label your PRs with automerge.

Github Pull Request Builder - Test this please not trigger build

I've configured the Github Pull Request Builder following the instructions in README
It seems work via cron ONLY - it runs the job every hour. However, directly commenting "test this please" or push to repository does not trigger the build. I've a 'bot' jenkins-user as admin in my repository. I've also enabled github-webhook and /jenkins/ghprbhook under Webhooks & Services
I want to know how the PR Builder react to the "test this please" comment.. is there a way I can monitor it?
Basically, if you follow the instruction and setup the Pull Request Builder, it's a cron.
For every periodic run, it detects if there's a new commit or "test this please" comment after last check. If yes, then it will trigger the build.
Note that, GHPRB will create a temp branch that merges your PR code to default branch. And it will alert you if there's conflict in the code.
It's retest this please
If the regular push to the repo does not work, the PR part won't work as well. In my experience the regular push was easier to get working
Are you sure that your account on GitHub can push to the repo and that you have set the correct endpoint for the hook on GitHub?

How to stop TeamCity from building a pull request when it is viewed or commented?

Currently, my team is using TeamCity to automatically build pull requests from GitHub.
We have a configuration to build all the pull requests. In the version control settings of the config, our branch specification is
+:refs/pull/*/merge
In the "Build Triggers" configuration setting, we have only one trigger with the following trigger rule:
+:root=Pull Requests on our Repository:\***/*\*
"Pull Requests on our Repository" is our VCS root name.
The issues:
When someone views a pull request on GitHub website without doing anything else, a build would be triggered in the TeamCity build agent. This is quite annoying, because from time to time, we have multiple build agents building the same pull requests (when multiple people view it).
When someone comments on a pull request, a build would also be triggered.
From my perspective, the only time I want TeamCity to start a build is when new commits are pushed to the pull requests.
Is there a way to do it?
Github's refs/pull/*/merge branches are updated every time mergeability of the branch is recalculated, i.e. on every commit to destination (most likely master) branch. They are also updated when pull request is closed and then reopened. Github's support says these branches are not intended for end users use. The only workaround at the moment is to run builds on refs/pull/*/head branches automatically and on refs/pull/*/merge branches manually.
Do you have TeamCity configured as per this blog post? I then activate the TeamCity service hook in GitHub which takes care of triggering a build in TeamCity whenever there is a push. This seems to do the right thing for me. Or am I missing something?
I know this is old but I wanted to post what we've found as alternatives:
Stop using VCS roots altogether as a mechanism for triggering pull requests. Instead, configure a GitHub webhook to notify a web app of yours whenever there is an update to a PR and only then trigger a build via the TeamCity REST API.
In your build config, add a step that checks what changed in the PR. If nothing changed (i.e. no new commits were added), or if the PR is closed, cancel the build. The problem with this is that the build queue will still be populated with builds that will then be cancelled. Also, you'd have to store somewhere the last commit that was built in order to do the check.
According to their TeamCity's issue tracker, the issue of the TeamCity.GitHub plugin causing an infinite loop of builds was fixed in v9.0