Is there any option to run github action via email - github

I need to send an email to github and then it need to run github action with input
Is that possible?
Or i need to make a push to master via email

You cannot start a workflow directly from email, but you can use manual events
You can manually trigger a workflow run using the GitHub API and from GitHub. For more information, see "Manually running a workflow."
Here are all available events that can trigger a workflow.
There are examples for starting workflow from slack, so I suppose you can implement something triggered by mail (if you can add a listener that checks all new emails and if specific email is send to call the GitHub API)

Related

Azure Devops Build Complete Notifications aren't firing

Azure DevOps "Build Complete" Notifications aren't firing when there is auto-trigger fires the build because of a commit in the bitbucket git repo. The build and release complete with no issues but the email notifications don't go to all at all to the team members. The end goal trying to achieve is to send an email to the administrator and the user who has checked the code in the bitbucket repo.
By reference to this doc: Supported subscriptions, we can subscribe notification of Build completed, as below. Thus only members of artifact-demo Team can receive notification which meet the filter criteria.
From your snapshot, it is out-of-the-box (OOB) or default subscriptions, and will send notifications to all subscribers, by default. Thus members of Dev Team can receive notification.
Therefore, if you have a CI pipeline for bitbucket repository, and want to send an email to the administrator and the user (we call it contributor) who has checked the code in the bitbucket repo via Azure DevOps notification service, please make sure that the administrator and the contributor are members of Dev team, so they will get build completed notification. Otherwise, they need to subscribe such notification via Personal notifications or Team notifications
Update>>If you want to only send notifications to the administrator and contributor, you could choose "Custom email address" and then set up multiple subsciptions.
Or the administrator and contributor can subscribe this notification via Personal notifications.
BTW, if some users doesn't want to receive such notifications, they can manually unsubscribe it.
Update2>>Using custom email address will send email to specific user. And if you have 20 members, there might be too many subscriptions, you could consider to add these 20 members to a new group/team(NotificatoinTeam), and then just need to subscribe this notification for this group and choose "Members of NotificatoinTeam", so everything is done. If there is new member wants to get this notification, just adds them to this group/team. Also if some members don't want to get this notification, just remove them from this NotificatoinTeam group/team.
Update3>>You could use this predefined variable Build.RequestedForEmail to get the contributor's email. See: Build variables (DevOps Services) for more details.

Merge PR by Github action if review was approved by a user

Is it possible to configure Github actions workflow to merge pull request if it was approved (submitted review with approve keyword) by one of the users (static fixed list, which can be written in workflow config file)? I tried to find it in documentation: https://help.github.com/en/articles/workflow-syntax-for-github-actions#on
- I suppose I can use on: [pull_request_review] trigger for action, but documentation didn't mention how to access event payload in action yaml file, where I need to extract reviewer login from this payload.
I found this in https://help.github.com/en/articles/virtual-environments-for-github-actions#filesystems-on-github-hosted-machines:
workflow/event.json: The POST payload of the webhook event that triggered the workflow. GitHub rewrites this each time an action executes to isolate file content between actions. Use the GITHUB_EVENT_PATH environment variable to access this file.
So the next step will be figuring out how to parse a JSON file and extract some data that a later step can use. For that, looking at GitHub's setup-dotnet action might prove useful. In line 62 of installer.ts, they call a function called core.exportVariable, which as you can see here, causes ##[set-env name=NAME;]value to be printed in the action's output. I've personally verified that this causes the environment variable called NAME to automatically be present in later steps of the same workflow job.
Now, I don't yet know if you can simply do echo "##[set-env name=NAME;]$VALUE" in a run step of a GitHub workflow and have that work; it's possible that you'll have to write a custom action in Typescript to get access to core.exportVariable. But once you have parsed the JSON, that would be one way of passing that information on to later steps in your job.
In addition of rmunn's answer, you might also want to protect your branch:
GitHub Actions: Prevent GitHub Actions from approving pull requests (2022, 14th Jan.)
We have introduced a new policy setting that controls whether GitHub Actions can approve pull requests.
This protects against a user using Actions to satisfy the "Required approvals" branch protection requirement and merging a change that was not reviewed by another user.
To prevent breaking existing workflows, Allow GitHub Actions reviews to count towards required approval is enabled by default.
However, an organization admin can disable it under the organization's Actions settings.
That way, you are sure approvals were made exclusively by users, not by other actions.

How to trigger an event in VSTS when there is a state change

Am looking to create a trigger (A json payload to a server) when an User Story is changed to closed/resolved state.
I am following this documentation
How to trigger an event in VSTS when there is a state change
First, Azure Devops has capabilities to set up email notifications for the work Item. Check this the document Manage your notifications for some more details.
For you requirement, you could add a new subscription with following settings:
Then, if any User Story is changed to closed/resolved state, you will receive a e-mail about it.
Besides, if the trigger event is more than just a e-mail notification, like build. You could configure a service hook to send request to build related builds:
Check this thread for the details.
Hope this helps.

How do I send non-default Github webhook to SNS?

Currently, I have followed this tutorial and set up Lambda, Github and my SNS for receiving responses from GitHub.
However, I am getting only the default webhook through this setting.
How do I customise it to work with one of the other non-default events here, like a pull-request (other than just push)?
In GitHub (https://github.com///settings/hooks/new) click on the radio button under Which events would you like to trigger this webhook? and select Send me everything.

How do you configure a github organization's repo to send notification emails about all events?

The webhooks guide lists email as one of the available services, however it seems that this only kicks off when a user actually pushes a change to the repository. How can you configure it so that an email is fired off for every event concerning that repo - issues opened/closed, pull requests, etc.?
You cannot, currently. See this pull request to the github-services which would enable at least pull request notification by email, but it was never merged by GitHub.
As a work-around I currently use IFTTT on my Android device to get notified about pull requests by email.