Github Actions trigger when add user to repository - github

I am m new in GitHub actions, and unfortunately I did not find any info about trigger on adding user to repo.
Is there somethinglike this in GitHub Actions?

The "Events that trigger workflows" page does not list indeed anything regarding a new user/collaborator being added to a repository.
As such, this does not appear to be a supported event.
You might consider a scheduled event to monitor at regular interval a repository, querying the list of collaborators (GitHub API), and triggering another job if the number changes.

Related

GitHub Actions is not permitted to create or approve pull requests (createPullRequest)

Since the 3rd of May this month, github added the setting Allow GitHub Actions to create and approve pull requests for creating pull requests in github actions, under Settings > Actions > General. However, it seems I cannot select this option for my repo, it is grayed out without any explanation why it is grayed out.
Whenever the "default permissions" setting is changed and saved, it is possible to select the Allow GitHub Actions to create and approve pull requests, but if it is saved it snaps back to the original grayed out version, unchecked.
I also tried giving the workflow file the pull-request permission like so:
permissions:
pull-requests: write
but that didn't work either. Is there something I am missing which prevents me from using pull requests within github actions?
You are probably using an organization, which means you must first enable this behavior on the organization level and then on the repository level
Go to https://github.com/organizations/YOUR_ORG/settings/actions and check Allow GitHub Actions to create and approve pull requests
Then go to https://github.com/YOUR_ORG/YOUR_REPO/settings/actions and check the box that previously was grayed out

How to make Github Action be triggered by push events of another repositorie

I want to automatically merge a repo to mine, if I cant't is there any other way to do this?
Here is a GitHub Action that enables you to trigger workflows in your repository as soon as an event happens on another repository: https://github.com/convictional/trigger-workflow-and-wait
Here is a nice blog by the creator of the Action which documents on how you can use the Action effectively: https://keithweaver.ca/lessons/trigger-another-repositorys-github-action-workflow-wait-for-result

Initiating Github webook based on new branch creation called "Release-XXXX"

Does anyone know if you can trigger a webhook based on the github action of creating a new branch called
Release-xxxx where XXXX can be anything? I only want to initiate this webhook on that new branch name.
In general, GitHub webhooks cover a single large category of activities that you are then responsible for filtering. In your case, you can install a webhook to be notified when a new branch or tag is created and then perform the filtering yourself.
GitHub doesn't perform the filtering for you because filtering is expensive and there are a lot of operations to notify about. This is no different than reading an events stream API and having to select only the events that you're interested in.

Automatically merge verified and tested GitHub Pull Requests

I'd like to automatically (i.e. from Jenkins) merge a GitHub pull request that has been approved by a person and has been tested successfully; in other words, when all THREE of these checkmarks are green:
Is this possible? I haven't found any documentation on an API for GitHub's new "changes approved" code review functionality.
There is a new PullRequestReviewEvent webhook that is triggered when a review is submitted in a non-pending state. The body of the webhook contains the ["review"]["state"] field, which will be approved when all reviewers have approved the changes (i.e. when you get the green "changes approved" tick in the UI).
Combine this with the StatusEvent for the head SHA of your pull request to get the status checks from CI and so on, then finally check the "merge-ability" of the pull by requesting the pull request from the API:
GET /repos/:owner/:repo/pulls/:number
Once you have all three things, you can merge the pull request with:
PUT /repos/:owner/:repo/pulls/:number/merge
and appropriate payload parameters. Note you'll need the Accept: application/vnd.github.polaris-preview+json for some of the payload parameters as they are in a preview period.
Official documentation: "Managing auto-merge for pull requests in your repository".
That is now (Dec. 2020, 4 years later) available:
Pull request auto-merge public beta
Pull request auto-merge is now rolling out as a public beta!
With auto-merge, pull requests can be automatically merged when all requirements for merging are met. No more waiting for long checks to finish just so you can press the merge button!
To use auto-merge, a repository maintainer or admin must first toggle on the repository setting to allow auto-merge (see steps).
Then any user with write permission can enable or disable auto-merge by navigating to the pull request page.
Keep in mind that auto-merge is only available for pull requests targeting a branch with required reviews or required status checks, and therefore is only available on public repositories and private repositories on Team and GitHub Enterprise Cloud plans.
Learn more about pull request auto-merge.
Update Feb. 2021:
Pull request auto-merge is now generally available
With auto-merge, pull requests can be set to merge automatically when all merge requirements are met.
No more waiting on slow CI jobs or tests to finish just so you can click the merge button!
To use auto-merge, first have an administrator allow auto-merge in the repository settings.
Then to enable auto-merge, navigate to the pull request on GitHub.com or GitHub Mobile and tap the button to enable.
Note that auto-merge can only be enabled by users with permission to merge and when there are unsatisfied merge requirements, like missing approvals or failing required status checks.
GraphQL APIs will be rolling out later this week. The pull request webhook event also now includes actions that indicate when auto-merge is enabled or disabled.
Learn more about pull request auto-merge
However, as The Godfather mentions in the comments:
The problem with this is that it doesn't do auto-update.
So as soon as your repo has "branches must be up-to-date" and some other PR got merged, this "auto-merge" doesn't work any more.
It should have been called the same way as Gitlab: "merge when pipeline succeeds", at least it's not as confusing... –
Update Aug. 2021:
Maintainers can now manage the availability of auto-merge in a repository
Maintainers can now manage the repository-level "Allow auto-merge" setting.
This setting, which is off by default, controls whether auto-merge is available on pull requests in the repository.
Previously, only admins could manage this setting.
Additionally, this setting can now by controlled using the "Create a repository" and "Update a repository" REST APIs.
I wrote an app that does this. It responds to the review, labelled, and commit status/checks events, and merges when the merge button is green.
The fact that it merges when the merge button is green means that you can configure the requirements for a mergeable PR in the GitHub settings, there's no need to write separate configuration for the app.
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.
You can use Mergify to do exactly this, since this is what it has been created for. Just set up a minimal .mergify.yml file in your repository:
rules:
default:
protection:
required_status_checks:
context:
- continuous-integration/travis/pr
required_pull_request_reviews:
required_approving_review_count: 1
And you'll be good to go.
(disclaimer: I'm one of the Mergify founders)
Using github actions which is one of the new ways, this can be done. I have written a blog about auto approving and auto merging PRs using github actions. However, if the intent is to just merge the PRs only, then then the second job in this work flow would be enough to do it.
https://github.com/bobvanderlinden/probot-auto-merge is a free GitHub app that does the job. It's configurable in .github/auto-merge.yml.

Is it possible to change github pull request title when merging the PR

We have just moved across to Targetprocess. It looked like it had good github integration, when a commit to that branch has "id:[storyid]" in the title it will detect it and setup the reference.
The issue we have is that we all use forks and create pull requests to merge stories / changes back into the main organisations repository. Github will not allow us to change the title (that I can see) and Targetprocess does not look at the comments section for the id:[storyid].
Is there a way to be able to change github to allow the merge commit to have the id:[userstory] text in the title?
https://help.github.com/articles/merging-a-pull-request/#merging-a-pull-request-using-the-github-web-interface states that GitHub allows to change message while merging PR via browser interface.
The same applies to the command line interface.