[GH-ISSUE #720] Issue: GitHub Actions says workflow is not valid because of ${{ !env.ACT }} #456

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

Originally created by @merlinstardust on GitHub (Jun 3, 2021).
Original GitHub issue: https://github.com/nektos/act/issues/720

Expected behaviour

GitHub Actions should not error regarding ${{ !env.ACT }}

Actual behaviour

GitHub Actions says workflow is not valid because of ${{ !env.ACT }}

The workflow is not valid. .github/workflows/deploy.yml (Line: 11, Col: 13): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT

Workflow and/or repository

Erroring Workflow

workflow
name: Deploy
on:
    push:
        branches:
            - release
    # run for every pull request
    pull_request: {}
jobs:
    deploy:
        name: Deploy
        if: ${{ !env.ACT }} # skip during local actions testing
        runs-on: ubuntu-latest
        strategy:
            matrix:
                node: [12]
        steps:
            - name: Checkout repo
              uses: actions/checkout@v2

            - name: Setup node
              uses: actions/setup-node@v1
              with:
                  node-version: ${{ matrix.node }}

            - name: 📥 Download deps
              uses: bahmutov/npm-install@v1
              with:
                  useLockFile: false

            - name: Deploy
              run: npx semantic-release@15

Originally created by @merlinstardust on GitHub (Jun 3, 2021). Original GitHub issue: https://github.com/nektos/act/issues/720 ## Expected behaviour GitHub Actions should not error regarding `${{ !env.ACT }}` ## Actual behaviour GitHub Actions says workflow is not valid because of `${{ !env.ACT }}` ``` The workflow is not valid. .github/workflows/deploy.yml (Line: 11, Col: 13): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT ``` ## Workflow and/or repository [Erroring Workflow](https://github.com/merlinpatt/paypal-messaging-components/actions/runs/903119301) <details> <summary>workflow</summary> ```none name: Deploy on: push: branches: - release # run for every pull request pull_request: {} jobs: deploy: name: Deploy if: ${{ !env.ACT }} # skip during local actions testing runs-on: ubuntu-latest strategy: matrix: node: [12] steps: - name: Checkout repo uses: actions/checkout@v2 - name: Setup node uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - name: 📥 Download deps uses: bahmutov/npm-install@v1 with: useLockFile: false - name: Deploy run: npx semantic-release@15 ``` </details>
kerem 2026-03-01 21:43:33 +03:00
Author
Owner

@github-actions[bot] commented on GitHub (Jul 4, 2021):

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

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

@merlinstardust commented on GitHub (Jul 4, 2021):

Keep

<!-- gh-comment-id:873553826 --> @merlinstardust commented on GitHub (Jul 4, 2021): Keep
Author
Owner

@catthehacker commented on GitHub (Jul 5, 2021):

That's a problem with GitHub and not Act.

<!-- gh-comment-id:874209464 --> @catthehacker commented on GitHub (Jul 5, 2021): That's a problem with GitHub and not Act.
Author
Owner

@merlinstardust commented on GitHub (Jul 5, 2021):

@catthehacker how do you suggest I fix it? Who should I contact? The docs for act include this line, but if it doesn't work with GitHub, that's a bug that should be fixed.

<!-- gh-comment-id:874216743 --> @merlinstardust commented on GitHub (Jul 5, 2021): @catthehacker how do you suggest I fix it? Who should I contact? The docs for act include this line, but if it doesn't work with GitHub, that's a bug that should be fixed.
Author
Owner

@catthehacker commented on GitHub (Jul 5, 2021):

act docs mention this but only for a step and it works on GitHub Actions, create issue on https://github.com/actions/runner to implement support for non-existing environment variables in job context of if:

github.com/nektos/act@dcbd5837af/README.md (L286-L296)

<!-- gh-comment-id:874247360 --> @catthehacker commented on GitHub (Jul 5, 2021): act docs mention this but only for a step and it works on GitHub Actions, create issue on https://github.com/actions/runner to implement support for non-existing environment variables in job context of `if:` https://github.com/nektos/act/blob/dcbd5837afc22b5d9beb79834771cd6a63d82bee/README.md#L286-L296
Author
Owner

@ChristopherHX commented on GitHub (Jul 6, 2021):

If you ask me your statement in a job-if is a syntax violation and is correctly rejected by github, but act has no such validation. The env context is only evaluated in the runner not the server (I made my own server).
Please consider using the github context instead:

name: Deploy
on:
    push:
        branches:
            - release
    # run for every pull request
    pull_request: {}
jobs:
    deploy:
        name: Deploy
        if: ${{ !github.event.act }} # skip during local actions testing
        runs-on: ubuntu-latest
        strategy:
            matrix:
                node: [12]
        steps:
            - name: Checkout repo
              uses: actions/checkout@v2

            - name: Setup node
              uses: actions/setup-node@v1
              with:
                  node-version: ${{ matrix.node }}

            - name: 📥 Download deps
              uses: bahmutov/npm-install@v1
              with:
                  useLockFile: false

            - name: Deploy
              run: npx semantic-release@15

And use this event.json file with act or Runner.Client otherwise the Job will run:

{
    "act": true
}

Run act like

act -e event.json

Hint: you can add / append -e event.json as a line into ./.actrc

<!-- gh-comment-id:874759066 --> @ChristopherHX commented on GitHub (Jul 6, 2021): If you ask me your statement in a job-if is a syntax violation and is correctly rejected by github, but act has no such validation. The env context is only evaluated in the runner not the server (I made my own server). Please consider using the `github` context instead: ```yml name: Deploy on: push: branches: - release # run for every pull request pull_request: {} jobs: deploy: name: Deploy if: ${{ !github.event.act }} # skip during local actions testing runs-on: ubuntu-latest strategy: matrix: node: [12] steps: - name: Checkout repo uses: actions/checkout@v2 - name: Setup node uses: actions/setup-node@v1 with: node-version: ${{ matrix.node }} - name: 📥 Download deps uses: bahmutov/npm-install@v1 with: useLockFile: false - name: Deploy run: npx semantic-release@15 ``` And use this `event.json` file with act or [Runner.Client](https://github.com/ChristopherHX/runner.server) otherwise the Job will run: ```json { "act": true } ``` Run act like ``` act -e event.json ``` _Hint: you can add / append `-e event.json` as a line into `./.actrc`_
Author
Owner

@diepes commented on GitHub (Sep 5, 2022):

I also just got the github error below.
Local with act it ran fine. I am trying to skip a job on local.

[Invalid workflow file: .github/workflows/ci.yml#L15](https://github.com/me/repo/actions/runs/2995855128/workflow) The workflow is not valid. .github/workflows/ci.yml (Line: 15, Col: 9): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT .github/workflows/ci.yml (Line: 39, Col: 9): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT

<!-- gh-comment-id:1237445575 --> @diepes commented on GitHub (Sep 5, 2022): I also just got the github error below. Local with act it ran fine. I am trying to skip a job on local. `[Invalid workflow file: .github/workflows/ci.yml#L15](https://github.com/me/repo/actions/runs/2995855128/workflow) The workflow is not valid. .github/workflows/ci.yml (Line: 15, Col: 9): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT .github/workflows/ci.yml (Line: 39, Col: 9): Unrecognized named-value: 'env'. Located at position 2 within expression: !env.ACT `
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#456
No description provided.