IF Conditions in Reusable Workflows

I have the following reusuable workflow defined:

name: "auto-approve"

on:
  workflow_call:
    inputs:
      auto-approve-user:
        description: Commits by this user in PRs created by this user (actor) to be auto-approved
        type: string
        default: 'dependabot[bot]'
    secrets:
      token:
        description: Github Token
        required: true

jobs:
  auto-approve:
    name: Auto-Approve PR Workflow
    runs-on: ubuntu-latest
    if: github.actor == ${{ inputs.auto-approve-user }}
    steps:
    - name: Perform Auto-Approve
      uses: hmarr/auto-approve-action@v2
      with:
        github-token: "${{ secrets.token }}"

When testing, I am seeing the “Perform Auto-Approve” step run no matter who the user is. I have put the IF condition on the job or the step and it still behaves the same way. I have also added some debug steps to output the “github.actor” and input value and they are correct (and different).

Do reusable workflows support conditional jobs or steps? If so, what am I doing wrong?

Regards,
Caleb

I think I figured it out. I believe I need the ${{ ... }} surrounding the condition. When I have that (and remove the braces around the input variable), it works!

So, that part becomes:

    if: ${{ github.actor == inputs.auto-approve-user }}
1 Like