[GH-ISSUE #940] Issue: if ${{ env.ACT }} not working on master #555

Closed
opened 2026-03-01 21:44:28 +03:00 by kerem · 5 comments
Owner

Originally created by @jayvdb on GitHub (Dec 23, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/940

System information

Expected behaviour

Assuming https://github.com/nektos/act#skipping-steps is still current for master

Steps with if: ${{ !env.ACT }} should be skipped.

Steps with if: ${{ env.ACT }} should not be skipped.

Actual behaviour

Steps with if: ${{ env.ACT }} are skipped.

Steps with if: ${{ !env.ACT }} are not skipped.

Workflow and/or repository

name: Foo
on:
  workflow_dispatch:
jobs:
  bar:
    name: Baz
    runs-on: ubuntu-latest
    steps:
      - name: Checkout action
        uses: actions/checkout@v2
      - name: Show env.ACT
        shell: bash
        run: echo "$ACT"
      - id: setup-python
        if: ${{ env.ACT }}
        name: Setup Python
        uses: actions/setup-python@v2
        with:
          python-version: '3.7'
      - if: ${{ !env.ACT }}
        name: not-ACT
        shell: bash
        run: echo "$ACT"

Steps to reproduce

  1. Install act from master
  2. Run on workflows that were previous working correctly with if: ${{ env.ACT }} or if: ${{ !env.ACT }} on v0.2.25
  3. Add "echo $ACT" to show it is being set to true

act output

[Foo/Baz] 🚀  Start image=catthehacker/ubuntu:act-latest
...
[Foo/Baz]   🐳  docker cp src=/Users/jayvdb/.../. dst=/Users/jayvdb/...
[Foo/Baz]   🐳  docker exec cmd=[mkdir -p /Users/jayvdb/...] user= workdir=
[Foo/Baz] ⭐  Run Checkout action
[Foo/Baz]   ✅  Success - Checkout action
[Foo/Baz] ⭐  Run Show env.ACT
[Foo/Baz]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1.sh] user= workdir=
| true
[Foo/Baz]   ✅  Success - Show env.ACT
[Foo/Baz] ⭐  Run not-ACT
[Foo/Baz]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/setup-python.sh] user= workdir=
| true
[Foo/Baz]   ✅  Success - not-ACT
Originally created by @jayvdb on GitHub (Dec 23, 2021). Original GitHub issue: https://github.com/nektos/act/issues/940 ## System information - Operating System: macOS - Architecture: x64 - Apple M1: no - Docker version: 20.10.10 - Docker image used in `act`: - `act` version: https://github.com/nektos/act/commit/ed01f464ede3515c94dedf5739b54576177bf80c (also a few few commits earlier https://github.com/nektos/act/commit/9868e1377274a7657d4aac6bd2b66c0d564405cb ) ## Expected behaviour Assuming https://github.com/nektos/act#skipping-steps is still current for `master` Steps with `if: ${{ !env.ACT }}` should be skipped. Steps with `if: ${{ env.ACT }}` should not be skipped. ## Actual behaviour Steps with `if: ${{ env.ACT }}` are skipped. Steps with `if: ${{ !env.ACT }}` are not skipped. ## Workflow and/or repository ```yaml name: Foo on: workflow_dispatch: jobs: bar: name: Baz runs-on: ubuntu-latest steps: - name: Checkout action uses: actions/checkout@v2 - name: Show env.ACT shell: bash run: echo "$ACT" - id: setup-python if: ${{ env.ACT }} name: Setup Python uses: actions/setup-python@v2 with: python-version: '3.7' - if: ${{ !env.ACT }} name: not-ACT shell: bash run: echo "$ACT" ``` ## Steps to reproduce 1. Install `act` from master 2. Run on workflows that were previous working correctly with `if: ${{ env.ACT }}` or `if: ${{ !env.ACT }}` on v0.2.25 3. Add "echo $ACT" to show it is being set to true ## `act` output ``` [Foo/Baz] 🚀 Start image=catthehacker/ubuntu:act-latest ... [Foo/Baz] 🐳 docker cp src=/Users/jayvdb/.../. dst=/Users/jayvdb/... [Foo/Baz] 🐳 docker exec cmd=[mkdir -p /Users/jayvdb/...] user= workdir= [Foo/Baz] ⭐ Run Checkout action [Foo/Baz] ✅ Success - Checkout action [Foo/Baz] ⭐ Run Show env.ACT [Foo/Baz] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1.sh] user= workdir= | true [Foo/Baz] ✅ Success - Show env.ACT [Foo/Baz] ⭐ Run not-ACT [Foo/Baz] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/setup-python.sh] user= workdir= | true [Foo/Baz] ✅ Success - not-ACT ```
kerem 2026-03-01 21:44:28 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Author
Owner

@ChristopherHX commented on GitHub (Dec 23, 2021):

I can confirm, this is broken in current master since github.com/nektos/act@1891c72ab1.

However https://github.com/nektos/act/pull/908 will fix this issue again, together with an improved expression evaluator.
I wonder why this feature doesn't have a testcase.

<!-- gh-comment-id:1000170128 --> @ChristopherHX commented on GitHub (Dec 23, 2021): I can confirm, this is broken in current master since https://github.com/nektos/act/commit/1891c72ab158508e36009d16b24913fa5836422b. However https://github.com/nektos/act/pull/908 will fix this issue again, together with an improved expression evaluator. I wonder why this feature doesn't have a testcase.
Author
Owner

@BlackDex commented on GitHub (Jan 20, 2022):

Maybe @ZauberNerd can add a proper test for this?
Something like:

name: if-env-act-test
on: push

jobs:
  if_env_test:
    name: Test if env.ACT matching
    runs-on: ubuntu-latest
    steps:
      # Should RUN, since we are running in act
      - name: Positive env.ACT match
        if: ${{ env.ACT }}
        shell: bash
        run: |
          echo "This workflow is run using act, continue!"
          echo "ACT: $ACT"
          exit 0

      # Should SKIP, since we are running in act
      - name: Negative env.ACT match
        if: ${{ !env.ACT }}
        shell: bash
        run: |
          echo "This should be skipped since this workflow is run using act, fail!"
          echo "ACT: $ACT"
          exit 1
<!-- gh-comment-id:1017633336 --> @BlackDex commented on GitHub (Jan 20, 2022): Maybe @ZauberNerd can add a proper test for this? Something like: ```yml name: if-env-act-test on: push jobs: if_env_test: name: Test if env.ACT matching runs-on: ubuntu-latest steps: # Should RUN, since we are running in act - name: Positive env.ACT match if: ${{ env.ACT }} shell: bash run: | echo "This workflow is run using act, continue!" echo "ACT: $ACT" exit 0 # Should SKIP, since we are running in act - name: Negative env.ACT match if: ${{ !env.ACT }} shell: bash run: | echo "This should be skipped since this workflow is run using act, fail!" echo "ACT: $ACT" exit 1 ```
Author
Owner

@ZauberNerd commented on GitHub (Jan 20, 2022):

@BlackDex I don't see how that test relates to the expression evaluator. IMHO it should be a separate PR to be merged after #908 has been merged.

<!-- gh-comment-id:1017688577 --> @ZauberNerd commented on GitHub (Jan 20, 2022): @BlackDex I don't see how that test relates to the expression evaluator. IMHO it should be a separate PR to be merged after #908 has been merged.
Author
Owner

@BlackDex commented on GitHub (Jan 20, 2022):

@ZauberNerd Well, the expression evaluator changes from PR #840 broke this and according to @ChristopherHX PR #908 fixes that issue, so maybe wise to have a test in there which prevents any further breaking of this when working on this feature?

It sounds logical to me to have a test added to a PR which fixes a specific issue doesn't it?

<!-- gh-comment-id:1017701343 --> @BlackDex commented on GitHub (Jan 20, 2022): @ZauberNerd Well, the expression evaluator changes from PR #840 broke this and according to @ChristopherHX PR #908 fixes that issue, so maybe wise to have a test in there which prevents any further breaking of this when working on this feature? It sounds logical to me to have a test added to a PR which fixes a specific issue doesn't it?
Author
Owner

@ChristopherHX commented on GitHub (Jan 23, 2022):

@BlackDex I added your testworkflow in a new PullRequest, since the bug was fixed.

<!-- gh-comment-id:1019583472 --> @ChristopherHX commented on GitHub (Jan 23, 2022): @BlackDex I added your testworkflow in a new PullRequest, since the bug was fixed.
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#555
No description provided.