Search code examples
github-actionscicd

pull_request_target Github Action not triggering


I am creating a new GitHub Action workflow in my repository with the pull_request_target trigger on the closing of a pull request (to clean up allocated resources) from a branch to master. But it isn't triggering when I close the pull request (using the close pull request button in GitHub). I can't find what I'm doing wrong with my action

name: Pull request closing workflow

on:
  pull_request_target:
    types:
      - closed

jobs:
  target_test:
    runs-on: ubuntu-20.04
    steps:
      - name: echo 
        run: |
         echo "HELLO WORLD!"

Solution

  • Answering my own question. The pull_request_target trigger only runs from the master branch and I hadn't merged my PR yet, so it couldn't trigger. I merged the code and then it worked fine.