Github not getting triggered when the PR’s are closed but not merged

  Kiến thức lập trình

The workflow has to delete the branches with pattern ID- or id- as prefix for closed pull request. Below is the workflow file. But no action is triggered.

`
name: Delete branch when PR not merged

permissions:
id-token: write
contents: write

only trigger on pull request closed events

on:
pull_request:
types: [ closed ]

jobs:
run_only_when_pr_not_merged:
if: github.event_name == ‘pull_request’ && github.event.action ==’closed’ && github.event.pull_request.merged == false
runs-on: ubuntu-latest
steps:
– name: Extract branch name
shell: bash
run: echo “branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}” >> $GITHUB_OUTPUT
id: extract_branch

  - name: Delete branch
    uses: dawidd6/action-delete-branch@v3
    if: contains(steps.extract_branch.outputs.branch, 'ID-') || contains(steps.extract_branch.outputs.branch, 'id-') 
    with:
      github_token: ${{github.token}}
      branches: ${{ github.head_ref }}

`

Tried different if conditions in job and on condition in workflow

New contributor

user26336051 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT