Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger GitHub Workflow on Pull Request

I'm new to GitHub workflows so pardon the naive question. I want to set up a workflow that triggers when a pull request is opened or reopened. I set a workflow however it seems to only trigger when doing a PR from my branch to master.

My workflow was set up on master, is that why the workflow only triggers when a PR is to submitted to master? How can I change it so the workflow triggers when a PR is submitted to any branch in my repo?

Below is the workflow I set up:

# This is a basic workflow to help you get started with Actions

name: WorkflowTest

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  pull_request:
    types: [opened, reopened]

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: [self-hosted, common-8gb]

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      #- uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - uses: actions/checkout@v2
      - uses: actions/setup-node@v2
        with:
          node-version: "14"
      - run: npm install
      - run: npm --version


like image 958
JBerto Avatar asked May 19 '26 22:05

JBerto


1 Answers

This worked for me. It triggered the CI Action whenever I created a PR from a custom branch to develop. And also whenever I pushed new changes to develop

name: Groot-UI CI

on:
  pull_request:
    branches: [develop]
like image 177
vizsatiz Avatar answered May 23 '26 08:05

vizsatiz