[PR #604] [MERGED] Add various GitHub environment variables #1520

Closed
opened 2026-03-01 21:51:32 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/604
Author: @jsoref
Created: 4/4/2021
Status: Merged
Merged: 5/6/2021
Merged by: @mergify[bot]

Base: masterHead: github-action-path


📝 Commits (6)

📊 Changes

5 files changed (+127 additions, -36 deletions)

View changed files

📝 pkg/runner/run_context.go (+68 -35)
📝 pkg/runner/run_context_test.go (+43 -0)
📝 pkg/runner/runner.go (+1 -0)
📝 pkg/runner/step_context.go (+6 -1)
📝 pkg/runner/testdata/uses-composite/composite_action/action.yml (+9 -0)

📄 Description

Using a tool I wrote for something else... https://github.com/jsoref/gha-debug/runs/2017914814?check_suite_focus=true

GitHub
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
ANDROID_HOME=/usr/local/lib/android/sdk
ANDROID_NDK_HOME=/usr/local/lib/android/sdk/ndk-bundle
ANDROID_NDK_ROOT=/usr/local/lib/android/sdk/ndk-bundle
ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
ANT_HOME=/usr/share/ant
AZURE_EXTENSION_DIR=/opt/az/azcliextensions
BOOST_ROOT_1_72_0=/opt/hostedtoolcache/boost/1.72.0/x64
BOOTSTRAP_HASKELL_NONINTERACTIVE=1
CHROMEWEBDRIVER=/usr/local/share/chrome_driver
CHROME_BIN=/usr/bin/google-chrome
CI=true
CONDA=/usr/share/miniconda
DEBIAN_FRONTEND=noninteractive
DEPLOYMENT_BASEPATH=/opt/runner
DOTNET_MULTILEVEL_LOOKUP=0
DOTNET_NOLOGO=1
DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
GECKOWEBDRIVER=/usr/local/share/gecko_driver
GITHUB_ACTION=run2
GITHUB_ACTIONS=true
GITHUB_ACTION_REF=
GITHUB_ACTION_REPOSITORY=
GITHUB_ACTOR=jsoref
GITHUB_API_URL=https://api.github.com
GITHUB_BASE_REF=
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_b9659a7c-aad0-4984-83d7-702fbfbb212b
GITHUB_EVENT_NAME=push
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=
GITHUB_JOB=build
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_b9659a7c-aad0-4984-83d7-702fbfbb212b
GITHUB_REF=refs/heads/main
GITHUB_REPOSITORY=jsoref/gha-debug
GITHUB_REPOSITORY_OWNER=jsoref
GITHUB_RETENTION_DAYS=90
GITHUB_RUN_ID=615846162
GITHUB_RUN_NUMBER=8
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=4982c105c248122f310cf05c11fd050b3293d229
GITHUB_WORKFLOW=Debug
GITHUB_WORKSPACE=/home/runner/work/gha-debug/gha-debug
GOROOT=/opt/hostedtoolcache/go/1.15.8/x64
GOROOT_1_13_X64=/opt/hostedtoolcache/go/1.13.15/x64
GOROOT_1_14_X64=/opt/hostedtoolcache/go/1.14.15/x64
GOROOT_1_15_X64=/opt/hostedtoolcache/go/1.15.8/x64
GRADLE_HOME=/usr/share/gradle
HOME=/home/runner
HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar"
HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS=3650
HOMEBREW_NO_AUTO_UPDATE=1
HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew"
HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew"
INVOCATION_ID=cf44682287d6431da649601ec0fc1a87
ImageOS=ubuntu18
ImageVersion=20210219.1
JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
JAVA_HOME_11_X64=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64
JAVA_HOME_12_X64=/usr/lib/jvm/adoptopenjdk-12-hotspot-amd64
JAVA_HOME_8_X64=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64
JOURNAL_STREAM=9:20111
LANG=C.UTF-8
LEIN_HOME=/usr/local/lib/lein
LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.5-standalone.jar
PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/opt/pipx_bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG
PIPX_BIN_DIR=/opt/pipx_bin
PIPX_HOME=/opt/pipx
POWERSHELL_DISTRIBUTION_CHANNEL=GitHub-Actions-ubuntu18
RUNNER_OS=Linux
RUNNER_PERFLOG=/home/runner/perflog
RUNNER_TEMP=/home/runner/work/_temp
RUNNER_TOOL_CACHE=/opt/hostedtoolcache
RUNNER_TRACKING_ID=github_c5f7f2be-3b74-4305-b493-08b9e3b4b8a9
RUNNER_USER=runner
RUNNER_WORKSPACE=/home/runner/work/gha-debug
SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar
SHLVL=1
SWIFT_PATH=/usr/share/swift/usr/bin
USER=runner
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
_=/usr/bin/env
Act
ACT=true
CI=true
GITHUB_ACTION=1
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/main
GITHUB_REPOSITORY=jsoref/gha-debug
GITHUB_RUN_ID=1
GITHUB_RUN_NUMBER=1
GITHUB_SERVER_URL=https://github.com
GITHUB_SHA=4982c105c248122f310cf05c11fd050b3293d229
GITHUB_TOKEN=
GITHUB_WORKFLOW=Debug
GITHUB_WORKSPACE=/Users/jsoref/code/spelling-org/gha-debug
HOME=/root
HOSTNAME=docker-desktop
ImageOS=ubuntu18.04
NODE_VERSION=12.20.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/Users/jsoref/code/spelling-org/gha-debug
RUNNER_OS=Linux
RUNNER_TEMP=/tmp
RUNNER_TOOL_CACHE=/opt/hostedtoolcache
SHLVL=1
YARN_VERSION=1.22.5
_=/usr/bin/env
GitHub additions
AGENT_TOOLSDIRECTORY
ANDROID_HOME
ANDROID_NDK_HOME
ANDROID_NDK_ROOT
ANDROID_SDK_ROOT
ANT_HOME
AZURE_EXTENSION_DIR
BOOST_ROOT_1_72_0
BOOTSTRAP_HASKELL_NONINTERACTIVE
CHROMEWEBDRIVER
CHROME_BIN
CONDA
DEBIAN_FRONTEND
DEPLOYMENT_BASEPATH
DOTNET_MULTILEVEL_LOOKUP
DOTNET_NOLOGO
DOTNET_SKIP_FIRST_TIME_EXPERIENCE
GECKOWEBDRIVER
GITHUB_ACTION_REF
GITHUB_ACTION_REPOSITORY
GITHUB_BASE_REF
GITHUB_HEAD_REF
GITHUB_JOB
GITHUB_PATH
GITHUB_REPOSITORY_OWNER
GITHUB_RETENTION_DAYS
GOROOT
GOROOT_1_13_X64
GOROOT_1_14_X64
GOROOT_1_15_X64
GRADLE_HOME
HOMEBREW_CELLAR
HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS
HOMEBREW_NO_AUTO_UPDATE
HOMEBREW_PREFIX
HOMEBREW_REPOSITORY
INVOCATION_ID
ImageVersion
JAVA_HOME
JAVA_HOME_11_X64
JAVA_HOME_12_X64
JAVA_HOME_8_X64
JOURNAL_STREAM
LANG
LEIN_HOME
LEIN_JAR
PERFLOG_LOCATION_SETTING
PIPX_BIN_DIR
PIPX_HOME
POWERSHELL_DISTRIBUTION_CHANNEL
RUNNER_PERFLOG
RUNNER_TRACKING_ID
RUNNER_USER
RUNNER_WORKSPACE
SELENIUM_JAR_PATH
SWIFT_PATH
USER
VCPKG_INSTALLATION_ROOT
Act additions
ACT
GITHUB_TOKEN
HOSTNAME
NODE_VERSION
PWD
YARN_VERSION

Offhand, I think this is what I'd want:

Var Value
GITHUB_ACTION_PATH = set if there's an action running
GITHUB_ACTION_REF ''
GITHUB_ACTION_REPOSITORY ''
GITHUB_BASE_REF ''
GITHUB_HEAD_REF ''
GITHUB_JOB = parse from workflow (it's the active child of the top level jobs)
GITHUB_REPOSITORY_OWNER = guess from origin
GITHUB_RETENTION_DAYS 0
RUNNER_PERFLOG /dev/null
RUNNER_TRACKING_ID
RUNNER_WORKSPACE = GITHUB_WORKSPACE

fixes #603

Notes:

  • USER/RUNNER_USER might be more a matter of the image -- @catthehacker is going to fix this in their images
    • It's possible to write some hacky code to use whoami (or echo $USER) to calculate and fill in a RUNNER_USER, but it's unclear whether that's the right thing to do in general, and, again, it's hacky.
  • GITHUB_PATH is #566

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/604 **Author:** [@jsoref](https://github.com/jsoref) **Created:** 4/4/2021 **Status:** ✅ Merged **Merged:** 5/6/2021 **Merged by:** [@mergify[bot]](https://github.com/apps/mergify) **Base:** `master` ← **Head:** `github-action-path` --- ### 📝 Commits (6) - [`88133cc`](https://github.com/nektos/act/commit/88133ccc9d1b794e89b5f7414fa211bd70bcbab7) define GITHUB_ACTION_PATH #603 - [`542c81d`](https://github.com/nektos/act/commit/542c81d07d1fc2c743c48280d16605ebc617d910) Add more environment variables - [`c742a9c`](https://github.com/nektos/act/commit/c742a9ca58bfcee68f2c8afdaa66909aa13a94ee) Add job name - [`135fde0`](https://github.com/nektos/act/commit/135fde05371d19d2fcbbceb1fe7a243896ba25b5) fix: remove unnecessary variables - [`d59401a`](https://github.com/nektos/act/commit/d59401a4882a71440b36e019580988587f0e6e5d) feat: add `RepositoryOwner` - [`8b6e542`](https://github.com/nektos/act/commit/8b6e542b9bbc1533b391861bef7b222606001ff6) feat: add test for `getGithubContext()` ### 📊 Changes **5 files changed** (+127 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `pkg/runner/run_context.go` (+68 -35) 📝 `pkg/runner/run_context_test.go` (+43 -0) 📝 `pkg/runner/runner.go` (+1 -0) 📝 `pkg/runner/step_context.go` (+6 -1) 📝 `pkg/runner/testdata/uses-composite/composite_action/action.yml` (+9 -0) </details> ### 📄 Description Using a tool I wrote for something else... https://github.com/jsoref/gha-debug/runs/2017914814?check_suite_focus=true <details><summary> GitHub </summary> ``` AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache ANDROID_HOME=/usr/local/lib/android/sdk ANDROID_NDK_HOME=/usr/local/lib/android/sdk/ndk-bundle ANDROID_NDK_ROOT=/usr/local/lib/android/sdk/ndk-bundle ANDROID_SDK_ROOT=/usr/local/lib/android/sdk ANT_HOME=/usr/share/ant AZURE_EXTENSION_DIR=/opt/az/azcliextensions BOOST_ROOT_1_72_0=/opt/hostedtoolcache/boost/1.72.0/x64 BOOTSTRAP_HASKELL_NONINTERACTIVE=1 CHROMEWEBDRIVER=/usr/local/share/chrome_driver CHROME_BIN=/usr/bin/google-chrome CI=true CONDA=/usr/share/miniconda DEBIAN_FRONTEND=noninteractive DEPLOYMENT_BASEPATH=/opt/runner DOTNET_MULTILEVEL_LOOKUP=0 DOTNET_NOLOGO=1 DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 GECKOWEBDRIVER=/usr/local/share/gecko_driver GITHUB_ACTION=run2 GITHUB_ACTIONS=true GITHUB_ACTION_REF= GITHUB_ACTION_REPOSITORY= GITHUB_ACTOR=jsoref GITHUB_API_URL=https://api.github.com GITHUB_BASE_REF= GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_b9659a7c-aad0-4984-83d7-702fbfbb212b GITHUB_EVENT_NAME=push GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json GITHUB_GRAPHQL_URL=https://api.github.com/graphql GITHUB_HEAD_REF= GITHUB_JOB=build GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_b9659a7c-aad0-4984-83d7-702fbfbb212b GITHUB_REF=refs/heads/main GITHUB_REPOSITORY=jsoref/gha-debug GITHUB_REPOSITORY_OWNER=jsoref GITHUB_RETENTION_DAYS=90 GITHUB_RUN_ID=615846162 GITHUB_RUN_NUMBER=8 GITHUB_SERVER_URL=https://github.com GITHUB_SHA=4982c105c248122f310cf05c11fd050b3293d229 GITHUB_WORKFLOW=Debug GITHUB_WORKSPACE=/home/runner/work/gha-debug/gha-debug GOROOT=/opt/hostedtoolcache/go/1.15.8/x64 GOROOT_1_13_X64=/opt/hostedtoolcache/go/1.13.15/x64 GOROOT_1_14_X64=/opt/hostedtoolcache/go/1.14.15/x64 GOROOT_1_15_X64=/opt/hostedtoolcache/go/1.15.8/x64 GRADLE_HOME=/usr/share/gradle HOME=/home/runner HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar" HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS=3650 HOMEBREW_NO_AUTO_UPDATE=1 HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" INVOCATION_ID=cf44682287d6431da649601ec0fc1a87 ImageOS=ubuntu18 ImageVersion=20210219.1 JAVA_HOME=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 JAVA_HOME_11_X64=/usr/lib/jvm/adoptopenjdk-11-hotspot-amd64 JAVA_HOME_12_X64=/usr/lib/jvm/adoptopenjdk-12-hotspot-amd64 JAVA_HOME_8_X64=/usr/lib/jvm/adoptopenjdk-8-hotspot-amd64 JOURNAL_STREAM=9:20111 LANG=C.UTF-8 LEIN_HOME=/usr/local/lib/lein LEIN_JAR=/usr/local/lib/lein/self-installs/leiningen-2.9.5-standalone.jar PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/opt/pipx_bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin PERFLOG_LOCATION_SETTING=RUNNER_PERFLOG PIPX_BIN_DIR=/opt/pipx_bin PIPX_HOME=/opt/pipx POWERSHELL_DISTRIBUTION_CHANNEL=GitHub-Actions-ubuntu18 RUNNER_OS=Linux RUNNER_PERFLOG=/home/runner/perflog RUNNER_TEMP=/home/runner/work/_temp RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_TRACKING_ID=github_c5f7f2be-3b74-4305-b493-08b9e3b4b8a9 RUNNER_USER=runner RUNNER_WORKSPACE=/home/runner/work/gha-debug SELENIUM_JAR_PATH=/usr/share/java/selenium-server-standalone.jar SHLVL=1 SWIFT_PATH=/usr/share/swift/usr/bin USER=runner VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg _=/usr/bin/env ``` </details> <details> <summary>Act</summary> ``` ACT=true CI=true GITHUB_ACTION=1 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/main GITHUB_REPOSITORY=jsoref/gha-debug GITHUB_RUN_ID=1 GITHUB_RUN_NUMBER=1 GITHUB_SERVER_URL=https://github.com GITHUB_SHA=4982c105c248122f310cf05c11fd050b3293d229 GITHUB_TOKEN= GITHUB_WORKFLOW=Debug GITHUB_WORKSPACE=/Users/jsoref/code/spelling-org/gha-debug HOME=/root HOSTNAME=docker-desktop ImageOS=ubuntu18.04 NODE_VERSION=12.20.1 PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin PWD=/Users/jsoref/code/spelling-org/gha-debug RUNNER_OS=Linux RUNNER_TEMP=/tmp RUNNER_TOOL_CACHE=/opt/hostedtoolcache SHLVL=1 YARN_VERSION=1.22.5 _=/usr/bin/env ``` </details> <details> <summary> GitHub additions </summary> ``` AGENT_TOOLSDIRECTORY ANDROID_HOME ANDROID_NDK_HOME ANDROID_NDK_ROOT ANDROID_SDK_ROOT ANT_HOME AZURE_EXTENSION_DIR BOOST_ROOT_1_72_0 BOOTSTRAP_HASKELL_NONINTERACTIVE CHROMEWEBDRIVER CHROME_BIN CONDA DEBIAN_FRONTEND DEPLOYMENT_BASEPATH DOTNET_MULTILEVEL_LOOKUP DOTNET_NOLOGO DOTNET_SKIP_FIRST_TIME_EXPERIENCE GECKOWEBDRIVER GITHUB_ACTION_REF GITHUB_ACTION_REPOSITORY GITHUB_BASE_REF GITHUB_HEAD_REF GITHUB_JOB GITHUB_PATH GITHUB_REPOSITORY_OWNER GITHUB_RETENTION_DAYS GOROOT GOROOT_1_13_X64 GOROOT_1_14_X64 GOROOT_1_15_X64 GRADLE_HOME HOMEBREW_CELLAR HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS HOMEBREW_NO_AUTO_UPDATE HOMEBREW_PREFIX HOMEBREW_REPOSITORY INVOCATION_ID ImageVersion JAVA_HOME JAVA_HOME_11_X64 JAVA_HOME_12_X64 JAVA_HOME_8_X64 JOURNAL_STREAM LANG LEIN_HOME LEIN_JAR PERFLOG_LOCATION_SETTING PIPX_BIN_DIR PIPX_HOME POWERSHELL_DISTRIBUTION_CHANNEL RUNNER_PERFLOG RUNNER_TRACKING_ID RUNNER_USER RUNNER_WORKSPACE SELENIUM_JAR_PATH SWIFT_PATH USER VCPKG_INSTALLATION_ROOT ``` </details> <details> <summary> Act additions </summary> ``` ACT GITHUB_TOKEN HOSTNAME NODE_VERSION PWD YARN_VERSION ``` </details> Offhand, I think this is what I'd want: Var | Value -|- GITHUB_ACTION_PATH | = set if there's an action running GITHUB_ACTION_REF | `''` GITHUB_ACTION_REPOSITORY | `''` GITHUB_BASE_REF | `''` GITHUB_HEAD_REF | `''` GITHUB_JOB | = parse from workflow (it's the active child of the top level `jobs`) GITHUB_REPOSITORY_OWNER | = guess from `origin` GITHUB_RETENTION_DAYS | `0` RUNNER_PERFLOG | `/dev/null` RUNNER_TRACKING_ID RUNNER_WORKSPACE | = GITHUB_WORKSPACE fixes #603 Notes: * `USER`/`RUNNER_USER` might be more a matter of the image -- @catthehacker is going to fix this in their images * It's possible to write some hacky code to use `whoami` (or `echo $USER`) to calculate and fill in a `RUNNER_USER`, but it's unclear whether that's the right thing to do in general, and, again, it's hacky. * `GITHUB_PATH` is #566 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-01 21:51:32 +03:00
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#1520
No description provided.