github notification to nodeJS when master get a commit - node.js

Is it possible if my master branch in my github repo gets an update that my nodeJS server got a notification ? so i can do stuff with it ? like get the version tag and commit message ?

First you need to go to your repo, and click through this sequence:
Settings -> Webhooks & Services -> Add webhook
Then paste the url where github will submit data for each new commit. You can find examples of payload in example.
Then implement the logic needed in the backend to work with info about new commits.

Related

Enabling pre-receive server hook to get PR/MR approval before pushing to dev branch

Use case: I have code on my local machine and If I try to push it to remote server, a pre-receive hook in remote [GitLab] server should get triggered and ask for respective author approval to merge that code onto Gitlab repo.
After [code review] if author approves MR then code from my local repo will be pushed to remote server else push needs to be halted.
I am sure that I was asked to enable pre-receive hook on GitLab server side and not on client side.
I think it is not possible because code exists in developer's local machine and hence approver may not be able to do code review but not sure about pre-receive working.
Can pre-receive hook able to notify approver before code push? If it is possible need to know how?
If not, I want a strong valid point to negotiate😒
MR approval is not requested when one pushed a branch, but only when one makes (once the branch is pushed) a merge request to the target branch.
In your case:
protect the dev branch (nobody can push directly to it, so no need for a pre-receive hook)
make a merge request mandatory for that branch
make sure to configure your merge requests so that they must be approved before they can be merged.
That means any code eventually merged to dev:
will not have been pushed directly to dev (MR required)
will have been reviewed and approved first, before being accepted and merged to dev.
While it is true enforcing the MR approval process, meaning disabling the "Merge" button as long as approval is not met, is not free (premium only), you still have a way to enforce it.
Make sure nobody can push/merge to dev is a "Merge Manager" who is alone responsible to merge or not the MRs. If said merge manager sees there is no approval, they won't merge the MR.

Skip Gitlab Webhook from git or merge request message

I have branch, lets called "dev" branch, I attach a webhook to call codemagic build every push/merge request on this branch.
But sometimes, I push/merge request with WIP feature, so I dont want to trigger a webhook when my commit message/merge request message contains "WIP".
Is it possible to do that on gitlab? I don't see any documentation of it.
use [skip ci] inside the commit message or pull request title

how to delete a pull request with pull number using github api [duplicate]

I accidentally made a wrong pull request and ended up closing the request myself. It's in a closed state right now but it's accessible via direct URL and showing on my activity bar.
Is there any way to delete a pull request completely so it's no longer accessible via URL or shows up on your activity history?
There is no way you can delete a pull request yourself -- you and the repo owner (and all users with push access to it) can close it, but it will remain in the log. This is part of the philosophy of not denying/hiding what happened during development.
However, if there are critical reasons for deleting it (this is mainly violation of Github Terms of Service), Github support staff will delete it for you.
Whether or not they are willing to delete your PR for you is something you can easily ask them, just drop them an email at support#github.com
UPDATE: Currently Github requires support requests to be created here: https://support.github.com/contact
5 step to do what you want if you made the pull request from a forked repository:
reopen the pull request
checkout to the branch which you made the pull request
reset commit to the last master commit(that means remove all you new code). Command: git reset --hard commit_hash_here
git push --force
delete your forked repository which made the pull request
And everything is done, good luck!
This is the reply I received from Github when I asked them to delete a pull request:
"Thanks for getting in touch! Pull requests can't be deleted through the UI at the moment and we'll only delete pull requests when they contain sensitive information like passwords or other credentials."
It's very easy actually:
You can empty it, that's the best you could do.
Go to your local
Copy your local branch unwanted-branch (against which the PR was opened) to a new branch new-branch. This copying is relevant if you want to back it up for any reason. Otherwise go to step 3.
$ git branch -b new-branch
$ git merge unwanted-branch
$ git push
Empty the unwanted-branch
$ git checkout unwanted-branch
$ git reset --hard HEAD~n #n is the number of commit the branch has
$ git push -f
Enjoy, your PR is empty and closed now ;). Go to remote and delete the unwanted-branch if it bothers you.

Gitlab project bot commit author as an authenticated user

I'm trying to set up a self-hosted Gitlab project with renovate to automatically create merge requests for dependency updates.
I created a Gitlab project token/bot with the name "renovate" which resolves to "project_123_bot". The rub is that my project uses push rules to "Check whether the commit author is a GitLab user". I do not know what I should use as the git commit author for renovate-generated commits. I've tried:
Renovate Bot <renovate#gitlab.myorg.com>
Renovate Bot <project_123_bot>
Renovate Bot <project_123_bot#gitlab.myorg.com>
among others, and I always get this rejection when pushing:
remote: GitLab: Author 'project_123_bot#gitlab.myorg.com' is not a member of team
What is the appropriate git commit author to use for project bots? Is it not possible for project bots to commit changes as a verified authenticated user?
The correct email seems to be project123_bot#example.com. I need to look into where the example.com comes from.
Edit: "example.com" is hard-coded, see https://gitlab.com/gitlab-org/gitlab/-/issues/292668

Can't enable Gitlab notification email for failed pipeline

so I want to get email notification for failed pipeline builds, I tried to configure my gitlab settings as following: https://docs.gitlab.com/ee/workflow/notifications.html
But in my settings I see following:
There is no check box for Failed/Successful pipeline.
For the project I set it to 'Watch:' receive notifications from projects or groups user is a member of.
What am I missing?
Even if the question is old, the solution is the Gitlab Integration "Pipeline emails" (suggested by this other answer).
In short, in your project, go to Project -> Settings -> Integrations -> Pipelines emails and set the list of emails to notify.
The link to https://docs.gitlab.com/ee/workflow/notifications.html is no more active.
I found a blog post from 2020 on https://about.gitlab.com/blog/, explaining how to do.
Read it there : https://about.gitlab.com/blog/2020/06/17/notification-on-pipeline-succeeds/
In short, you have checkboxes for custom notification events like :
failed pipeline
fixed pipeline
successful pipeline
etc.
To access it, like said in the blog post,
Go to the Project overview page for the project.
Click the "bell" 🔔 (Notification setting) button and select Custom.
And before all, check your global notification email at : https://gitlab.com/-/profile/notifications

Resources