Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github actions on push and on pull_request difference

on push and on pull_request difference in github actions?

On every pull request we are pushing our code then why do we need on push and on pull_request isn't just on push enough?

like image 871
Rishabh Jain Avatar asked Aug 30 '25 15:08

Rishabh Jain


2 Answers

You can trigger only on pushes to master or pull requests to master. This will prevent builds from happening twice when somebody opens a pull request against master and then pushes updates to their branch.

For example:

on:
  push:
    branches:
    - master
  pull_request:
    branches:
    - master
like image 164
Davis Vue.js Developer Avatar answered Sep 04 '25 08:09

Davis Vue.js Developer


on push and on pull_request difference in github actions?

In general, push will trigger when you push code where pull_request will trigger when there is a pull request.

They overlap when you create PRs from the same repo, but you need pull_request if you want to run an action when you receive a PR from a fork for example. You need push when you want to run an action when something is push. You can fine tune them depending on the behaviour you expect to avoid duplication of jobs.

like image 44
acm Avatar answered Sep 04 '25 07:09

acm