[GH-ISSUE #2418] GITHUB_* variables are empty #1112

Open
opened 2026-03-01 21:48:59 +03:00 by kerem · 7 comments
Owner

Originally created by @AndesKrrrrrrrrrrr on GitHub (Aug 7, 2024).
Original GitHub issue: https://github.com/nektos/act/issues/2418

Bug report info

act version:            0.2.65
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	$XDG_RUNTIME_DIR/podman/podman.sock
Config files:           
	/var/home/person/.config/act/actrc:
		-P ubuntu-latest=catthehacker/ubuntu:act-latest
		-P ubuntu-22.04=catthehacker/ubuntu:act-22.04
		-P ubuntu-20.04=catthehacker/ubuntu:act-20.04
		-P ubuntu-18.04=catthehacker/ubuntu:act-18.04
Build info:
	Go version:            go1.22.5
	Module path:           command-line-arguments
	Main version:          
	Main path:             
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.65
		DefaultGODEBUG:       httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
		CGO_ENABLED:          1
		CGO_CFLAGS:           
		CGO_CPPFLAGS:         
		CGO_CXXFLAGS:         
		CGO_LDFLAGS:          
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1

Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

Command used with act

act push -W .github/workflows/empty-env.yml

Describe issue

Some GITHUB_*_REF variables are empty, even though Act claims on its front page to provide these variables.

These are empty:

GITHUB_REF_TYPE=          
GITHUB_ACTION_PATH=       
GITHUB_ACTION_REPOSITORY= 
GITHUB_BASE_REF=          
GITHUB_HEAD_REF=          
GITHUB_ACTION_REF=        

https://github.com/AndesKrrrrrrrrrrr/act-MWE/tree/main

Workflow content

name: Empty env MWE

on:
  pull_request: {}
  push: {}

jobs:
  prepare:
    runs-on: ubuntu-latest
    steps:
      - run: |
          set -x
          env | grep "^GITHUB_"
      - run: |
          set -euxo pipefail
          [[ -n "$GITHUB_HEAD_REF" ]] &&
          [[ -n "$GITHUB_BASE_REF" ]] &&
          [[ -n "$GITHUB_SHA" ]] &&
          true

Relevant log output

INFO[0000] Using docker host 'unix:///run/user/1000/podman/podman.sock', and daemon socket 'unix:///run/user/1000/podman/podman.sock' 
[Empty env MWE/prepare] 🚀  Start image=catthehacker/ubuntu:act-latest
[Empty env MWE/prepare]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[Empty env MWE/prepare]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Empty env MWE/prepare]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[Empty env MWE/prepare]   🐳  docker exec cmd=[node --no-warnings -e console.log(process.execPath)] user= workdir=
[Empty env MWE/prepare] ⭐ Run Main set -x
env | grep "^GITHUB_"
[Empty env MWE/prepare]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| + env
| + grep '^GITHUB_'
| GITHUB_WORKSPACE=/var/home/person/work/act-MWE
| GITHUB_PATH=/var/run/act/workflow/pathcmd.txt
| GITHUB_ACTION=0
| GITHUB_RUN_NUMBER=1
| GITHUB_REF_TYPE=
| GITHUB_ACTIONS=true
| GITHUB_SHA=a5d48eb18b2b0aeeb31487335ac644aa69d689c3
| GITHUB_REF=refs/pull/%!f(<nil>)/merge
| GITHUB_API_URL=https://api.github.com
| GITHUB_STATE=/var/run/act/workflow/statecmd.txt
| GITHUB_ENV=/var/run/act/workflow/envs.txt
| GITHUB_EVENT_PATH=/var/run/act/workflow/event.json
| GITHUB_EVENT_NAME=pull_request
| GITHUB_RUN_ID=1
| GITHUB_STEP_SUMMARY=/var/run/act/workflow/SUMMARY.md
| GITHUB_ACTOR=nektos/act
| GITHUB_GRAPHQL_URL=https://api.github.com/graphql
| GITHUB_ACTION_PATH=
| GITHUB_SERVER_URL=https://github.com
| GITHUB_REF_NAME=%!f(<nil>)/merge
| GITHUB_JOB=prepare
| GITHUB_REPOSITORY=AndesKrrrrrrrrrrr/act-MWE
| GITHUB_RETENTION_DAYS=0
| GITHUB_ACTION_REPOSITORY=
| GITHUB_BASE_REF=
| GITHUB_REPOSITORY_OWNER=AndesKrrrrrrrrrrr
| GITHUB_HEAD_REF=
| GITHUB_ACTION_REF=
| GITHUB_WORKFLOW=Empty env MWE
| GITHUB_OUTPUT=/var/run/act/workflow/outputcmd.txt
[Empty env MWE/prepare]   ✅  Success - Main set -x
env | grep "^GITHUB_"
[Empty env MWE/prepare] ⭐ Run Main set -euxo pipefail
[[ -n "$GITHUB_HEAD_REF" ]] &&
[[ -n "$GITHUB_BASE_REF" ]] &&
[[ -n "$GITHUB_SHA" ]] &&
true
[Empty env MWE/prepare]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
| + [[ -n '' ]]
[Empty env MWE/prepare]   ❌  Failure - Main set -euxo pipefail
[[ -n "$GITHUB_HEAD_REF" ]] &&
[[ -n "$GITHUB_BASE_REF" ]] &&
[[ -n "$GITHUB_SHA" ]] &&
true
[Empty env MWE/prepare] exitcode '1': failure
[Empty env MWE/prepare] 🏁  Job failed
Error: Job 'prepare' failed

Additional information

No response

Originally created by @AndesKrrrrrrrrrrr on GitHub (Aug 7, 2024). Original GitHub issue: https://github.com/nektos/act/issues/2418 ### Bug report info ```plain text act version: 0.2.65 GOOS: linux GOARCH: amd64 NumCPU: 16 Docker host: DOCKER_HOST environment variable is not set Sockets found: $XDG_RUNTIME_DIR/podman/podman.sock Config files: /var/home/person/.config/act/actrc: -P ubuntu-latest=catthehacker/ubuntu:act-latest -P ubuntu-22.04=catthehacker/ubuntu:act-22.04 -P ubuntu-20.04=catthehacker/ubuntu:act-20.04 -P ubuntu-18.04=catthehacker/ubuntu:act-18.04 Build info: Go version: go1.22.5 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.65 DefaultGODEBUG: httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: amd64 GOOS: linux GOAMD64: v1 Error: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? ``` ### Command used with act ```sh act push -W .github/workflows/empty-env.yml ``` ### Describe issue Some `GITHUB_*_REF` variables are empty, even though Act claims on its front page to provide these variables. These are empty: ``` GITHUB_REF_TYPE= GITHUB_ACTION_PATH= GITHUB_ACTION_REPOSITORY= GITHUB_BASE_REF= GITHUB_HEAD_REF= GITHUB_ACTION_REF= ``` ### Link to GitHub repository https://github.com/AndesKrrrrrrrrrrr/act-MWE/tree/main ### Workflow content ```yml name: Empty env MWE on: pull_request: {} push: {} jobs: prepare: runs-on: ubuntu-latest steps: - run: | set -x env | grep "^GITHUB_" - run: | set -euxo pipefail [[ -n "$GITHUB_HEAD_REF" ]] && [[ -n "$GITHUB_BASE_REF" ]] && [[ -n "$GITHUB_SHA" ]] && true ``` ### Relevant log output ```sh INFO[0000] Using docker host 'unix:///run/user/1000/podman/podman.sock', and daemon socket 'unix:///run/user/1000/podman/podman.sock' [Empty env MWE/prepare] 🚀 Start image=catthehacker/ubuntu:act-latest [Empty env MWE/prepare] 🐳 docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true [Empty env MWE/prepare] 🐳 docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Empty env MWE/prepare] 🐳 docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [Empty env MWE/prepare] 🐳 docker exec cmd=[node --no-warnings -e console.log(process.execPath)] user= workdir= [Empty env MWE/prepare] ⭐ Run Main set -x env | grep "^GITHUB_" [Empty env MWE/prepare] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir= | + env | + grep '^GITHUB_' | GITHUB_WORKSPACE=/var/home/person/work/act-MWE | GITHUB_PATH=/var/run/act/workflow/pathcmd.txt | GITHUB_ACTION=0 | GITHUB_RUN_NUMBER=1 | GITHUB_REF_TYPE= | GITHUB_ACTIONS=true | GITHUB_SHA=a5d48eb18b2b0aeeb31487335ac644aa69d689c3 | GITHUB_REF=refs/pull/%!f(<nil>)/merge | GITHUB_API_URL=https://api.github.com | GITHUB_STATE=/var/run/act/workflow/statecmd.txt | GITHUB_ENV=/var/run/act/workflow/envs.txt | GITHUB_EVENT_PATH=/var/run/act/workflow/event.json | GITHUB_EVENT_NAME=pull_request | GITHUB_RUN_ID=1 | GITHUB_STEP_SUMMARY=/var/run/act/workflow/SUMMARY.md | GITHUB_ACTOR=nektos/act | GITHUB_GRAPHQL_URL=https://api.github.com/graphql | GITHUB_ACTION_PATH= | GITHUB_SERVER_URL=https://github.com | GITHUB_REF_NAME=%!f(<nil>)/merge | GITHUB_JOB=prepare | GITHUB_REPOSITORY=AndesKrrrrrrrrrrr/act-MWE | GITHUB_RETENTION_DAYS=0 | GITHUB_ACTION_REPOSITORY= | GITHUB_BASE_REF= | GITHUB_REPOSITORY_OWNER=AndesKrrrrrrrrrrr | GITHUB_HEAD_REF= | GITHUB_ACTION_REF= | GITHUB_WORKFLOW=Empty env MWE | GITHUB_OUTPUT=/var/run/act/workflow/outputcmd.txt [Empty env MWE/prepare] ✅ Success - Main set -x env | grep "^GITHUB_" [Empty env MWE/prepare] ⭐ Run Main set -euxo pipefail [[ -n "$GITHUB_HEAD_REF" ]] && [[ -n "$GITHUB_BASE_REF" ]] && [[ -n "$GITHUB_SHA" ]] && true [Empty env MWE/prepare] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir= | + [[ -n '' ]] [Empty env MWE/prepare] ❌ Failure - Main set -euxo pipefail [[ -n "$GITHUB_HEAD_REF" ]] && [[ -n "$GITHUB_BASE_REF" ]] && [[ -n "$GITHUB_SHA" ]] && true [Empty env MWE/prepare] exitcode '1': failure [Empty env MWE/prepare] 🏁 Job failed Error: Job 'prepare' failed ``` ### Additional information _No response_
Author
Owner

@ChristopherHX commented on GitHub (Aug 7, 2024):

..........

GITHUB_ACTION_PATH=
GITHUB_ACTION_REPOSITORY
GITHUB_ACTION_REF=

Those are empty as run is not an action, please check this against actions/runner

GITHUB_BASE_REF=
GITHUB_HEAD_REF=

act pull_request exclusive if -e provides specfic pr webhook keys
please check against actions/runner when your job runs via push

Do you have some suggestion to get the values? I believe we have documented how the event.json must look like, but that could be invalid didn't verify

GITHUB_REF_TYPE=

What is expected here for refs/pull ? I remember that was undefined while the code has been written and empty was correct

<!-- gh-comment-id:2273831921 --> @ChristopherHX commented on GitHub (Aug 7, 2024): .......... > GITHUB_ACTION_PATH= GITHUB_ACTION_REPOSITORY GITHUB_ACTION_REF= Those are empty as run is not an action, please check this against actions/runner > GITHUB_BASE_REF= GITHUB_HEAD_REF= act pull_request exclusive if `-e` provides specfic pr webhook keys please check against actions/runner when your job runs via push Do you have some suggestion to get the values? I believe we have documented how the event.json must look like, but that could be invalid didn't verify > GITHUB_REF_TYPE= What is expected here for refs/pull ? I remember that was undefined while the code has been written and empty was correct
Author
Owner

@AndesKrrrrrrrrrrr commented on GitHub (Aug 8, 2024):

GITHUB_ACTION_PATH=
GITHUB_ACTION_REPOSITORY
GITHUB_ACTION_REF=

Those are empty as run is not an action, please check this against actions/runner

Yeah, that makes sense. For now, I don't care about these anyways.

GITHUB_BASE_REF=
GITHUB_HEAD_REF=

act pull_request exclusive if -e provides specfic pr webhook keys please check against actions/runner when your job runs via push

What do you mean by this (act pull_request exclusive)?

Do you have some suggestion to get the values? I believe we have documented how the event.json must look like, but that could be invalid didn't verify

We can gather these independent of Github, since we know the base branch, and the current branch. We can set GITHUB_BASE_REF to the argument of --defaultbranch or create a new flag --basebranch (defaulting to --basebranch). GITHUB_HEAD_REF can be gathered from git as either the current branch name, or the current commit hash.

GITHUB_REF_TYPE=

What is expected here for refs/pull ? I remember that was undefined while the code has been written and empty was correct

From the docs, though, I've never used it myself or seen it used 🤷

The type of ref that triggered the workflow run. Valid values are branch or tag.

<!-- gh-comment-id:2276013863 --> @AndesKrrrrrrrrrrr commented on GitHub (Aug 8, 2024): > > GITHUB_ACTION_PATH= > > GITHUB_ACTION_REPOSITORY > > GITHUB_ACTION_REF= > > Those are empty as run is not an action, please check this against actions/runner Yeah, that makes sense. For now, I don't care about these anyways. > > GITHUB_BASE_REF= > > GITHUB_HEAD_REF= > > act pull_request exclusive if `-e` provides specfic pr webhook keys please check against actions/runner when your job runs via push What do you mean by this (`act pull_request exclusive`)? > Do you have some suggestion to get the values? I believe we have documented how the event.json must look like, but that could be invalid didn't verify We can gather these independent of Github, since we know the base branch, and the current branch. We can set `GITHUB_BASE_REF` to the argument of `--defaultbranch` or create a new flag `--basebranch` (defaulting to `--basebranch`). `GITHUB_HEAD_REF` can be gathered from `git` as either the current branch name, or the current commit hash. > > GITHUB_REF_TYPE= > > What is expected here for refs/pull ? I remember that was undefined while the code has been written and empty was correct From [the docs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/variables), though, I've never used it myself or seen it used :shrug: > The type of ref that triggered the workflow run. Valid values are `branch` or `tag`.
Author
Owner

@ChristopherHX commented on GitHub (Aug 10, 2024):

From the docs, though, I've never used it myself or seen it used 🤷

The type of ref that triggered the workflow run. Valid values are branch or tag

Yes, that is for refs/tag/ and refs/heads/, but we are writing about refs/pull/.
For branch and tag it is implemented.
Stll this has been empty on GH at one point of time for PR's (no push, no anything else), I don't verify such information periodically.

What do you mean by this (act pull_request exclusive)?

The trigger event name is checked:
Tbh, this looks like to miss pull_request_review and so on

github.com/nektos/act@bda491e406/pkg/model/github_context.go (L203)

act push never set's the value from event.json, but I think you don't provide such a file.

To set the value currently just do

act --env GITHUB_HEAD_REF=pr --env GITHUB_BASE_REF=main that has no event name filter. But then github.event doesn't mirror the value in the wenhook structure

github.com/nektos/act@bda491e406/pkg/runner/run_context.go (L880)

we know the base branch

I don't know it, I would need to guess it. A sha might be an unexpected value here

Not every PR goes to default branch, only most.

As a default fallback it's ok, you can make a pr, but please only for events contain pull_request in their name

GITHUB_HEAD_REF can be gathered from git as either the current branch name, or the current commit hash.

As a default fallback it's ok, you can make a pr, but please only for events contain pull_request in their name

<!-- gh-comment-id:2280094726 --> @ChristopherHX commented on GitHub (Aug 10, 2024): > From [the docs](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/variables), though, I've never used it myself or seen it used 🤷 > > > The type of ref that triggered the workflow run. Valid values are `branch` or `tag` Yes, that is for refs/tag/ and refs/heads/, but we are writing about refs/pull/. For branch and tag it is implemented. Stll this has been empty on GH at one point of time for PR's (no push, no anything else), I don't verify such information periodically. > What do you mean by this (`act pull_request exclusive`)? The trigger event name is checked: Tbh, this looks like to miss pull_request_review and so on https://github.com/nektos/act/blob/bda491e406db6c85865498ced18764bc00491a5e/pkg/model/github_context.go#L203 act push never set's the value from event.json, but I think you don't provide such a file. To set the value currently just do `act --env GITHUB_HEAD_REF=pr --env GITHUB_BASE_REF=main` that has no event name filter. But then github.event doesn't mirror the value in the wenhook structure https://github.com/nektos/act/blob/bda491e406db6c85865498ced18764bc00491a5e/pkg/runner/run_context.go#L880 > we know the base branch I don't know it, I would need to guess it. A sha might be an unexpected value here Not every PR goes to default branch, only most. As a default fallback it's ok, you can make a pr, but please only for events contain pull_request in their name > `GITHUB_HEAD_REF` can be gathered from `git` as either the current branch name, or the current commit hash. As a default fallback it's ok, you can make a pr, but please only for events contain pull_request in their name
Author
Owner

@github-actions[bot] commented on GitHub (Feb 7, 2025):

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

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

@AndesKrrrrrrrrrrr commented on GitHub (May 21, 2025):

@ChristopherHX, can we please remove the github stalebot? This is still an issue, and won't magically stop being an issue because a bot saw that the issue is "old".

<!-- gh-comment-id:2898929124 --> @AndesKrrrrrrrrrrr commented on GitHub (May 21, 2025): @ChristopherHX, can we please remove the github stalebot? This is still an issue, and won't magically stop being an issue because a bot saw that the issue is "old".
Author
Owner

@ChristopherHX commented on GitHub (May 21, 2025):

@AndesKrrrrrrrrrrr What is your point?

The last commit to act removed the stale bot

https://github.com/nektos/act/pull/2745

Disabling stalebot != reopen every issue with label stale.

<!-- gh-comment-id:2899020966 --> @ChristopherHX commented on GitHub (May 21, 2025): @AndesKrrrrrrrrrrr What is your point? The last commit to act removed the stale bot > https://github.com/nektos/act/pull/2745 Disabling stalebot != reopen every issue with label stale.
Author
Owner

@AndesKrrrrrrrrrrr commented on GitHub (May 22, 2025):

@ChristopherHX, it was a snarky comment on stalebots. I'm happy to see you've disabled it 😄

My bad on the comment right after it being disabled; funny coincidence.

<!-- gh-comment-id:2902042939 --> @AndesKrrrrrrrrrrr commented on GitHub (May 22, 2025): @ChristopherHX, it was a snarky comment on stalebots. I'm happy to see you've disabled it 😄 My bad on the comment right after it being disabled; funny coincidence.
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#1112
No description provided.