[GH-ISSUE #597] Issue: with fields should only be evaluated if if evaluates to true #396

Closed
opened 2026-03-01 21:43:01 +03:00 by kerem · 2 comments
Owner

Originally created by @jsoref on GitHub (Apr 2, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/597

Act version

act version 9a7bc6

Expected behaviour

Evaluate an if for a step, if it evaluates to true, evaluate the with fields, if not, skip them.

Actual behaviour

with fields are evaluated first (resulting in errors)

Workflow and/or repository

workflow

github.com/jsoref/spell-check-this@4101393f8d/.github/workflows/spelling.yml

Note: ${{ ... }} wrappings for the if were added to this workflow to make act happy, but per GitHub they should be implied. (I'll file a bug for that later.)

name: Spell checking
on:
  pull_request_target:
  push:
  issue_comment:
  pull_request_review_comment:

jobs:
  build:
    name: Spell checking
    runs-on: ubuntu-latest
    steps:
    - name: checkout-merge
      if: "${{ contains(github.event_name, 'pull_request') }}"
      uses: actions/checkout@v2.0.0
      with:
        ref: refs/pull/${{github.event.pull_request.number}}/merge
        fetch-depth: 5
    - name: checkout
      if: "${{ !contains(github.event_name, 'pull_request') }}"
      uses: actions/checkout@v2.0.0
      with:
        fetch-depth: 5
    - uses: check-spelling/check-spelling@0.0.17-alpha
      with:
        experimental_apply_changes_via_bot: 1

Steps to reproduce

act output

act -v

Log
DEBU[0018] Found revision: 4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 
DEBU[0018] Loading revision from git directory '/Users/jsoref/code/spelling-org/spell-check-this/.git' 
DEBU[0018] Found revision: 4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 
DEBU[0018] HEAD points to '4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03' 
DEBU[0018] HEAD matches refs/heads/prerelease           
DEBU[0018] using github ref: refs/heads/prerelease      
DEBU[0018] context env => map[ACT:true]                 
DEBU[0018] context env => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_ENV:/Users/jsoref/code/spelling-org/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/Users/jsoref/code/spelling-org/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_REF:refs/heads/prerelease GITHUB_REPOSITORY:git@github.com:check-spelling/spell-check-this GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 GITHUB_TOKEN: GITHUB_WORKFLOW:Spell checking GITHUB_WORKSPACE:/Users/jsoref/code/spelling-org/spell-check-this INPUT_FETCH-DEPTH:5 INPUT_REF:refs/pull/${{github.event.pull_request.number}}/merge ImageOS:ubuntu20] 
DEBU[0018] Evaluating 'github['event']['pull_request']['number']' instead of 'github.event.pull_request.number' 
ERRO[0018] Unable to interpolate string 'refs/pull/${{github.event.pull_request.number}}/merge' - [TypeError: Cannot access member 'number' of undefined] 
[Spell checking/Spell checking] setupEnv => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GIT

The if ${{ contains(github.event_name, 'pull_request') }} should result in false (the default is push).

Originally created by @jsoref on GitHub (Apr 2, 2021). Original GitHub issue: https://github.com/nektos/act/issues/597 <!-- - Make sure you are able to reproduce it on the [latest version](https://github.com/nektos/act/releases) - Search the existing issues. - Refer to [README](https://github.com/nektos/act/blob/master/README.md). --> ## Act version <!-- Paste output of `act --version` --> ```none act version 9a7bc6 ``` ## Expected behaviour <!-- Describe how whole process should go and finish --> Evaluate an `if` for a `step`, if it evaluates to `true`, evaluate the `with` fields, if not, skip them. ## Actual behaviour <!-- Describe what happened --> `with` fields are evaluated first (resulting in errors) ## Workflow and/or repository <details> <summary>workflow</summary> https://github.com/jsoref/spell-check-this/blob/4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03/.github/workflows/spelling.yml Note: `${{ ... }}` wrappings for the if were added to this workflow to make `act` happy, but per GitHub they should be implied. (I'll file a bug for that later.) ```none name: Spell checking on: pull_request_target: push: issue_comment: pull_request_review_comment: jobs: build: name: Spell checking runs-on: ubuntu-latest steps: - name: checkout-merge if: "${{ contains(github.event_name, 'pull_request') }}" uses: actions/checkout@v2.0.0 with: ref: refs/pull/${{github.event.pull_request.number}}/merge fetch-depth: 5 - name: checkout if: "${{ !contains(github.event_name, 'pull_request') }}" uses: actions/checkout@v2.0.0 with: fetch-depth: 5 - uses: check-spelling/check-spelling@0.0.17-alpha with: experimental_apply_changes_via_bot: 1 ``` </details> ## Steps to reproduce <!-- Make sure to include command you used to run `act` e.g.: 1. Clone example repo (https://github.com/cplee/github-actions-demo) 2. Enter cloned repo directory 3. Run `act -s SUPER_SECRET=im-a-value` --> ## `act` output <!-- Paste output from your terminal, use `-v` or `--verbose` for richer output --> `act -v` <details> <summary>Log</summary> ```none DEBU[0018] Found revision: 4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 DEBU[0018] Loading revision from git directory '/Users/jsoref/code/spelling-org/spell-check-this/.git' DEBU[0018] Found revision: 4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 DEBU[0018] HEAD points to '4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03' DEBU[0018] HEAD matches refs/heads/prerelease DEBU[0018] using github ref: refs/heads/prerelease DEBU[0018] context env => map[ACT:true] DEBU[0018] context env => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_ENV:/Users/jsoref/code/spelling-org/workflow/envs.txt GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/Users/jsoref/code/spelling-org/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_REF:refs/heads/prerelease GITHUB_REPOSITORY:git@github.com:check-spelling/spell-check-this GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:4101393f8d4d21cbaadaf88c3ac1b7ad3754bc03 GITHUB_TOKEN: GITHUB_WORKFLOW:Spell checking GITHUB_WORKSPACE:/Users/jsoref/code/spelling-org/spell-check-this INPUT_FETCH-DEPTH:5 INPUT_REF:refs/pull/${{github.event.pull_request.number}}/merge ImageOS:ubuntu20] DEBU[0018] Evaluating 'github['event']['pull_request']['number']' instead of 'github.event.pull_request.number' ERRO[0018] Unable to interpolate string 'refs/pull/${{github.event.pull_request.number}}/merge' - [TypeError: Cannot access member 'number' of undefined] [Spell checking/Spell checking] setupEnv => map[ACT:true CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GIT ``` </details> The if `${{ contains(github.event_name, 'pull_request') }}` should result in `false` (the default is `push`).
kerem 2026-03-01 21:43:01 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (May 3, 2021):

Issue is stale and will be closed in 14 days unless there is new activity

<!-- gh-comment-id:830933349 --> @github-actions[bot] commented on GitHub (May 3, 2021): Issue is stale and will be closed in 14 days unless there is new activity
Author
Owner

@jsoref commented on GitHub (May 3, 2021):

Still live

<!-- gh-comment-id:830969993 --> @jsoref commented on GitHub (May 3, 2021): Still live
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#396
No description provided.