Skip to content

How can I trigger it on the branch of the PR? #100

@dunklesToast

Description

@dunklesToast

Hi,

I'm trying to implement a custom workflow which runs on the branch of the PR where the command was triggered.

My trigger looks like this:

name: Dispatcher
on:
  issue_comment:
    types: [created]

jobs:
  slashCommandDispatch:
    runs-on: ubuntu-latest
    if: ${{ github.event.issue.pull_request }}
    steps:
      - name: Slash Command Dispatch
        uses: peter-evans/slash-command-dispatch@v2
        with:
          token: ${{ secrets.REPO_PAT }}
          allow-edits: true
          reaction-token: ${{ secrets.REPO_PAT }}
          permission: write
          dispatch-type: workflow
          ref: ${{ env.GITHUB_REF }}
          commands: |
            test

If I write /test in my PR it'll trigger the dispatcher and also the action which listens on the Event but it will alway use the main branch. Is there a way to use the PR branch? As you can see I tried using the ref argument but thats not recognized.

My custom action to be triggered looks like this:

name: Testing

on:
  workflow_dispatch:

jobs:
  jest:
    name: Run Jest
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

I verfied that the commit hash was wrong in the GitHub UI:
image
This commit is from the main branch and not from my PR:
image

Expected behaviour would be, that it checks out the branch which is associated with the Pull Request where I typed the command. Is this even possible?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions