Github branch protection rules/status checks - github

I'd like to create a branch protection rule for our main branch in a way that if the "enforce-pr-naming-convention" github workflow fails for a pull request event, the pull request merge button should be disabled. Though the workflow is present in .github/workflows , was tested and works fine, I can't see & select it under settings/branches.
expectation:
https://i.stack.imgur.com/pmRPS.png
reality:
https://i.stack.imgur.com/SRoi6.png
Any idea on how to solve this?

Related

How to test github workflow without merging into master/main branch

I am creating a new git workflow. And just like any other piece of code, I want to test it separately without having to merge it into master first.
This will also help if I have to make few corrections if something doesn't work in the workflow yaml.
Here is the mechanism that I am looking for:
main branch has .github folder which contains all workflows
I create a branch and add my workflow to .github folder
Now I should be able to see(somewhere on Github) workflows from my branch running
When I know that workflows are working fine, I merge my branch in master
Now under github 'Action' tab, new workflows will reflect
Is there a way to do this?
I am actually doing workflow testing all the name, as you can see this test workflow workflow-level-notification is not merged into master branch (ie default branch), and I can still see the workflows in the UI.
Like GuiFalourd said, you can also use act to do the local testing as well. But working directly in the github repo is not that bad. (you can delete the workflow after)
If you would like to test non PR triggerd actions you can simply update your default branch temporarially, run the actions for test, then when you are done switch back.

To enable commit button in github

My commit button is not getting enabled after editing Readme file in github.
The reason why the commit button is not enabled is because you are trying to commit to the master branch of the repo, which is protected from making direct commits/push. Only those who have access to make direct commits to master can do that, and you might not have that access. Hence you need to select the second option there to create a new branch to make the commit and create a pull request to the master branch, or get access to directly contribute to that branch.
The branch protection is to ensure that collaborators don't directly push or make commits to the particular branch or delete it, and also allows enabling status checks or required reviews. You can read more about GitHub's branch protection here.

How completely protect/block branch in Azure Devops from Pull requests

I found how to block/protect branch from pushes, force pushes but how to protect branch from pull requests? When somebody creates pull requests branch merges with branch which locked (f.e. master branch) without any problems or acknowledges. How to protect branch from pull request Of course if it possible?
Branch lock (protect branch from pushes);
Branch security (deny force pushes)
I want to make impossible to complete pull request to locked branch. Of course if it possible.
I tested locking a branch, the result of the test is that it can successfully prevent other users from completing the pull request and merge to the target branch.
When I lock the master branch, and then create pr from the dev branch to the master branch, when I click complete, I will be prompted to stop me from completing the pr.
In addition, locking the branch can also prevent me from committing to the locked branch.
So I think locking branch can meet your need.For details ,please refer to this official document.
Plainly block branch from any PR isn't possible as a singular feature. But you can use branch policies to achieve something alike.
ADO docs says you can set policies:
Add specific person as required approver (it can be you)
Require minimum number of reviewers (you can add 999 person)
Check for linked work items
Require approval from external services (via API)
Plain locking branch forever and whatever happens is not the best approach (you want to have opportunity to do that sometimes). Hope that helps.
Hm strange. Because in our case lock not preventing from PR.
Probably it depends on who made PR. His privileges in Project but I'm not sure...
master branch lock
successfull PR

VSTS GitHub Pull Request Trigger Not Firing

I can't seem to get my VSTS build to trigger for GitHub pull requests. It works fine when i commit to the master branch, but not when i open the pull requests to the master branch.
Here's the screenshot from VSTS:
I can also see the 2x Webhooks in GitHub:
I can see the pull_request webhook fires successfully when i open a PR too (returns 200 ok), but VSTS doesn't seem to be triggering the build.
I'm guessing there's something obvious i've missed. Can someone help please?
As auto trigger is enabled only for master branch, I would suggest you add one more branch filter. Click on the add button and include other branches also.

github new local branch event for Jira webhook

I am noticing that when i create a new local branch, it doesn't get picked up in Github, and therefore the Jira webhook also doesn't create a transition trigger:
git branch -b new-local-branch
The Jira trigger is supposed to recognize "Branch created" event from Github webhook, but that doesn't exist until I push, which also then shows the new branch for the first time in the <>Code tab.
So, is this performing as expected, or is there another way to create a branch which gets pickedup without a push?
So, is this performing as expected
Yes: a webhook reacts to an event (here a push event).
As long as your branch remains local, said webhook has no reason to be activated.
But once created, you could push your branch immediately (before making any new commit in it): that would allow the webhook and Jira to pick up on it.
Is there another way to create a branch which gets picked-up without a push?
If you are creating your local branch from a commit which is already pushed, you could consider the reverse approach: creating your branch directly from GitHub web GUI. But that might not trigger the webhook though.