Trigger a workflow on completion of another workflow with right branch

I have a workflow that is set up to run/get triggered when a PR is merged successfully.

Snippet from workflow:

name: "On PR"

      - closed
      - develop

An example is I have a branch test where I made some changes and then created PR to merge test's changes into develop.

This workflow works fine and triggers as expected. On the workflow - run list it shows test as the branch while running the workflow - not develop.

Now I have another which is set to trigger when the above workflow is completed.

Snippet from this workflow:

        - "On PR"
        - develop
        - completed

I have two issues here.

  1. The Second workflow never gets triggered because the branches are set to develop if I set it to test then it does but branch test is dynamic and I have no control of what that would be so I want to trigger this considering the destination PR merge branch name for it.

  2. This second workflow gets triggered even if my previous PR merge workflow fails - how can I set it to only get triggered if “On PR” is completed successfully and not on fail.

Thanks in advance.

  1. See Workflow_run completed event triggered by failed workflow

    You can add github.event.workflow_run.conclusion == 'success' as if condition to jobs

@Simran-B thanks for the solution on point 2. That worked like a charm!