How to stop GitHub actions starting if a GitHub check has failed? - github

Currently, our team has limited GitHub actions in minutes, so I would only like to run GitHub actions when the WIP flag is not present.
Currently we use this plugin WIP to check if a branch is work in progress.
Is there a way that if the commit is flagged as WIP, that the GitHub actions to not trigger so we can conserve our monthly minutes allowance?

You should be able to use the pull_request event with the ready_for_review or even review_requested tags.
This example will only run when a pull request is marked ready for review.
on:
pull_request:
types: [ready_for_review]
Draft pull requests
Pull request trigger event

Related

Perform Github Action when trying to merge branch

I'm setting up Github actions for a few of my projects.
The flow I'd like to achieve is:
A developer clicks on the "Merge pull request" button
A Github action testing workflow will take place
If the tests pass - The merge is executed
The reason for this kind of flow, is I wouldn't like the tests to run on each commit pushed to the branch. I want the flow to run only when trying to merge.
My question is:
Is there a way to manually execute a workflow only when trying / wanting to merge, and making sure the branch can be merged into master if and only if the tests have passed?
Unfortunately, there's no merged or merge_attempt activity type on the pull request event (yet). Even if there was, I don't believe GitHub has a way to block merges on the completion of a workflow (yet).
What I would suggest as a workaround here is to run your test 1. after the fact on pushes to the master branch, and 2. on pull_request events with certain activity types which indicate that the user is likely to attempt a merge soon. For example, ready_for_review or review_requested.
Something like this:
name: tests
on:
push:
branches:
- master
pull_request:
branches:
- master
types:
- ready_for_review
- review_requested

Triggering Pull Request Builds automatically on draft pull requests in Azure DevOps (ADO)

If I make a pull request in ADO from one of my branches then any commits I push to my branch automatically trigger the build pipeline:
This is configured in the build validation branch policies on master:
But for draft pull requests I need to trigger builds manually:
The documentation (here) does not mention any distinction between active and draft pull requests. How do I configure my project so that commits to branches in a draft pull requests automatically trigger a build?
According to the docs:
Draft pull requests do not include reviewers or run builds by default
but allow you to manually add reviewers and run builds. To promote the
pull request to a normal pull request, simply click the Publish button
from the pull request detail page.
So, it looks like you experience the expected behavior.

Does Automated Commit are ignored by workflow hook?

We have two workflow that trigger on push set up like this:
on:
push:
branches:
- master
Inside of one workflow, it contains an action that push a bump version commit into master.
Inside of the other, it validate if the commit message is a bump and deploy automatically.
Currently, when we push a commit to master, we can see the github action created a commit in master like this:
Automated Version Bump ci: version bump to v1.2.3
Where Automated Version Bump is the name of the GitHub action and ci: version bump to v1.2.3 is the commit message generated by the GitHub action
I was expecting the workflow to trigger again because of the automated commit.
Does that means Automated Commit does not trigger workflow hook?
Thank you!
It seems this behaviour is a feature.
From the workflow events page:
An action in a workflow run can't trigger a new workflow run. For
example, if an action pushes code using the repository's GITHUB_TOKEN,
a new workflow will not run even when the repository contains a
workflow configured to run when push events occur.
So basically, events that originate from a workflow cannot trigger other workflows.
An alternative would be to use a scheduled workflow that checks every couple hours or so and does the validation.
on:
schedule:
- cron: '0 0/2 * * *'

Triggering Jenkins Multibranch pipeline when there is a pull request created in GitHub

I'm using Jenkins Multibranch pipeline. I've configured the APIs(github-webhook and ghprbhook) in GitHub. I want to trigger the Multibranch Pipeline whenever there is a Pull Request on GitHub (without using periodical option).
For example, if i create pull request on GitHub, then the Jenkins Multibranch pipeline should start scanning and build the Jenkinsfile automatically.
What do i need to do to achieve this?
I would love to try if there are any suggestions.
Under the webhook section, you can choose Let me select individual events option. Under that you can have push selected by default and also can select Pull Request which helps you to do wnat you are looking for Pull request opened, closed, reopened, edited, assigned, unassigned, review requested, review request removed, labeled, unlabeled, or synchronized.
To achieve this, I have selected "Send me everything" under GitHub Webhooks section.
Then I was able to trigger builds automatically whenever a PR is raised on GitHub.
As #RSharma mentioned, I have selected only "Push and Pull Request" under "Let me select individual events" section.
PS: The GitHub branches are automatically detected in Jenkins.

Setup rules/alerts before raising a PR in 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: