[GH-ISSUE #422] How to determine whether running workflows with act? #293

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

Originally created by @theowenyoung on GitHub (Nov 16, 2020).
Original GitHub issue: https://github.com/nektos/act/issues/422

Hi,

I can check if a workflow running in Github Actions by ${{ env.GITHUB_ACTIONS=='true'}}, but act also define env GITHUB_ACTIONS: true, so how to determine whether running workflows with act?

There are some steps that I only want to run with Github, not locally.

Example:

name: Build Site
on:
  workflow_dispatch:
  push:
jobs:
  run:
    runs-on: ubuntu-latest
    name: Run
    steps:
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@v3
        if: env.GITHUB_ACTION=='true'
        with:
          token: ${{ secrets.PERSONAL_TOKEN }}

How to define if condition?

Originally created by @theowenyoung on GitHub (Nov 16, 2020). Original GitHub issue: https://github.com/nektos/act/issues/422 Hi, I can check if a workflow running in Github Actions by `${{ env.GITHUB_ACTIONS=='true'}}`, but act also define env `GITHUB_ACTIONS: true`, so how to determine whether running workflows with act? There are some steps that I only want to run with Github, not locally. Example: ```yaml name: Build Site on: workflow_dispatch: push: jobs: run: runs-on: ubuntu-latest name: Run steps: - name: Create Pull Request uses: peter-evans/create-pull-request@v3 if: env.GITHUB_ACTION=='true' with: token: ${{ secrets.PERSONAL_TOKEN }} ``` How to define `if` condition?
kerem 2026-03-01 21:42:08 +03:00
  • closed this issue
  • added the
    stale
    label
Author
Owner

@austinsasko commented on GitHub (Nov 16, 2020):

I think this is something that can have an env var for act specifically. e.g. in the runner context code I can add a line for
env["ACT_LOCAL"] = "true" and some other code where needed (e.g. dist index.js in repo)

Then in the job you can specify
if: env.ACT_LOCAL=='true' and have that job only execute when running from act on your local machine

Would this provide you the functionality you are looking for?

<!-- gh-comment-id:728321579 --> @austinsasko commented on GitHub (Nov 16, 2020): I think this is something that can have an env var for act specifically. e.g. in the runner context code I can add a line for ` env["ACT_LOCAL"] = "true" ` and some other code where needed (e.g. dist index.js in repo) Then in the job you can specify `if: env.ACT_LOCAL=='true'` and have that job only execute when running from `act` on your local machine Would this provide you the functionality you are looking for?
Author
Owner

@theowenyoung commented on GitHub (Nov 16, 2020):

@austinsasko yes, that totally solves my problem..

<!-- gh-comment-id:728327995 --> @theowenyoung commented on GitHub (Nov 16, 2020): @austinsasko yes, that totally solves my problem..
Author
Owner

@torbjornvatn commented on GitHub (Nov 20, 2020):

This is actually solved in #417 which was merged to master yesterday.
It introduces an ACT=true environment variable

<!-- gh-comment-id:730731762 --> @torbjornvatn commented on GitHub (Nov 20, 2020): This is actually solved in #417 which was merged to master yesterday. It introduces an `ACT=true` environment variable
Author
Owner

@MattKiazyk commented on GitHub (Dec 4, 2020):

@torbjornvatn when can we expect a release that has #417 in it?

<!-- gh-comment-id:738548779 --> @MattKiazyk commented on GitHub (Dec 4, 2020): @torbjornvatn when can we expect a release that has #417 in it?
Author
Owner

@github-actions[bot] commented on GitHub (Jan 16, 2021):

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

<!-- gh-comment-id:761279549 --> @github-actions[bot] commented on GitHub (Jan 16, 2021): Issue is stale and will be closed in 14 days unless there is new activity
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#293
No description provided.