[GH-ISSUE #2081] Setting -s GITHUB_TOKEN=... causes a GITHUB_TOKEN env variable to be set in jobs #995

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

Originally created by @jenseng on GitHub (Nov 8, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/2081

Bug report info

act version:            0.2.53
GOOS:                   darwin
GOARCH:                 arm64
NumCPU:                 12
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
	$HOME/.docker/run/docker.sock
Config files:
	/Users/jonj/.actrc:
		-P ubuntu-latest=node:16-buster-slim
		-P ubuntu-22.04=node:16-bullseye-slim
		-P ubuntu-20.04=node:16-buster-slim
		-P ubuntu-18.04=node:16-buster-slim
Build info:
	Go version:            go1.21.3
	Module path:           command-line-arguments
	Main version:
	Main path:
	Main checksum:
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -X main.version=0.2.53
		DefaultGODEBUG:       panicnil=1
		CGO_ENABLED:          1
		CGO_CFLAGS:
		CGO_CPPFLAGS:
		CGO_CXXFLAGS:
		CGO_LDFLAGS:
		GOARCH:               arm64
		GOOS:                 darwin
Docker Engine:
	Engine version:        24.0.6
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Docker Desktop
	OS type:               linux
	OS version:
	OS arch:               aarch64
	OS kernel:             6.4.16-linuxkit
	OS CPU:                12
	OS memory:             7844 MB
	Security options:
		name=seccomp,profile=unconfined
		name=cgroupns

Command used with act

act -s GITHUB_TOKEN=thisisasecret -vW .github/workflows/sample.yml

Describe issue

If you set a GITHUB_TOKEN secret, a GITHUB_TOKEN env variable will automatically be set in jobs, even if you don't explicitly specify it in the env. This is inconsistent with actual GitHub Actions workflows; if you want a GITHUB_TOKEN env variable, you need to explicitly set it via env.

This is problematic since it can result in poorly written jobs "working" locally with act but then breaking when pushed to GitHub. I've run into this multiple times when I've written a job that uses the gh CLI but forgotten to actually set the GITHUB_TOKEN in env; my local test works, but then the real run fails 🫠

https://github.com/jenseng/dynamic-uses/actions/runs/6801630930/job/18492924811

Workflow content

name: test
on: push
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - run: echo "GITHUB_TOKEN is NOT set 😅"
        if: (!env.GITHUB_TOKEN)
      - run: |
          echo "::error::GITHUB_TOKEN is set but shouldn't be!"
          exit 1
        if: env.GITHUB_TOKEN

Relevant log output

WARN  ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠
DEBU[0000] Loading environment from /Users/jonj/projects/dynamic-uses/.env
DEBU[0000] Loading action inputs from /Users/jonj/projects/dynamic-uses/.input
DEBU[0000] Loading secrets from /Users/jonj/projects/dynamic-uses/.secrets
DEBU[0000] Loading vars from /Users/jonj/projects/dynamic-uses/.vars
DEBU[0000] Evaluated matrix inclusions: map[]
DEBU[0000] Loading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml'
DEBU[0000] Reading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml'
DEBU[0000] Conditional GET for notices etag=b769c9d4-c638-4197-b343-39d63c669434
DEBU[0000] Preparing plan with all jobs
DEBU[0000] Using the only detected workflow event: push
DEBU[0000] Planning jobs for event: push
DEBU[0000] gc: 2023-11-08 10:12:08.04153 -0700 MST m=+0.004306626  module=artifactcache
DEBU[0000] Plan Stages: [0x14000394330]
DEBU[0000] Stages Runs: [test]
DEBU[0000] Job.Name: test
DEBU[0000] Job.RawNeeds: {0 0    <nil> []    0 0}
DEBU[0000] Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    5 14}
DEBU[0000] Job.Env: {0 0    <nil> []    0 0}
DEBU[0000] Job.If: {0 0  success()  <nil> []    0 0}
DEBU[0000] Job.Steps: echo "GITHUB_TOKEN is NOT set 😅"
DEBU[0000] Job.Steps: echo "::error::GITHUB_TOKEN is set but shouldn't be!"
exit 1
DEBU[0000] Job.TimeoutMinutes:
DEBU[0000] Job.Services: map[]
DEBU[0000] Job.Strategy: <nil>
DEBU[0000] Job.RawContainer: {0 0    <nil> []    0 0}
DEBU[0000] Job.Defaults.Run.Shell:
DEBU[0000] Job.Defaults.Run.WorkingDirectory:
DEBU[0000] Job.Outputs: map[]
DEBU[0000] Job.Uses:
DEBU[0000] Job.With: map[]
DEBU[0000] Job.Result:
DEBU[0000] Empty Strategy, matrixes=[map[]]
DEBU[0000] Job Matrices: [map[]]
DEBU[0000] Runner Matrices: map[]
DEBU[0000] Final matrix after applying user inclusions '[map[]]'
DEBU[0000] Loading revision from git directory
DEBU[0000] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
DEBU[0000] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
DEBU[0000] using github ref: refs/heads/debug-act-bug5
DEBU[0000] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
DEBU[0000] Detected CPUs: 12
[test/test] [DEBUG] evaluating expression 'success()'
[test/test] [DEBUG] expression 'success()' evaluated to 'true'
[test/test] 🚀  Start image=node:16-buster-slim
INFO[0000] Parallel tasks (0) below minimum, setting to 1
[test/test]   🐳  docker pull image=node:16-buster-slim platform= username= forcePull=true
[test/test] [DEBUG]   🐳  docker pull node:16-buster-slim
[test/test] [DEBUG] pulling image 'docker.io/library/node:16-buster-slim' ()
DEBU[0000] Saving notices etag=b769c9d4-c638-4197-b343-39d63c669434
DEBU[0000] No new notices
[test/test] [DEBUG] Pulling from library/node :: 16-buster-slim
[test/test] [DEBUG] Digest: sha256:3ebf2875c188d22939c6ab080cfb1a4a6248cc86bae600ea8e2326aa03acdb8f ::
[test/test] [DEBUG] Status: Image is up to date for node:16-buster-slim ::
INFO[0001] Parallel tasks (0) below minimum, setting to 1
[test/test]   🐳  docker create image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[test/test] [DEBUG] Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:true OpenStdin:false StdinOnce:false Env:[RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:node:16-buster-slim Volumes:map[] WorkingDir:/Users/jonj/projects/dynamic-uses Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]}
[test/test] [DEBUG] Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:host PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[{Type:volume Source:act-toolcache Target:/toolcache ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b-env Target:/var/run/act ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b Target:/Users/jonj/projects/dynamic-uses ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>}] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>}
[test/test] [DEBUG] input.NetworkAliases ==> [test]
[test/test] [DEBUG] not a use defined config??
[test/test] [DEBUG] Created container name=act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b id=1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9 from image node:16-buster-slim (platform: )
[test/test] [DEBUG] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8]
[test/test]   🐳  docker run image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[test/test] [DEBUG] Starting container: 1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9
[test/test] [DEBUG] Started container: 1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9
[test/test] [DEBUG] Writing entry to tarball workflow/event.json len:2
[test/test] [DEBUG] Writing entry to tarball workflow/envs.txt len:0
[test/test] [DEBUG] Extracting content to '/var/run/act/'
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://172.24.80.224:49775/ CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_REF:refs/heads/debug-act-bug5 GITHUB_REF_NAME:debug-act-bug5 GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:jenseng/dynamic-uses GITHUB_REPOSITORY_OWNER:jenseng GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:26b632fc2f4f001e4e955fa13a7cafcbd01e9897 GITHUB_TOKEN:*** GITHUB_WORKFLOW:test GITHUB_WORKSPACE:/Users/jonj/projects/dynamic-uses ImageOS:ubuntu20 RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:]
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] evaluating expression '(!env.GITHUB_TOKEN)'
[test/test] [DEBUG] expression '(!env.GITHUB_TOKEN)' evaluated to 'false'
[test/test] [DEBUG] Skipping step 'echo "GITHUB_TOKEN is NOT set 😅"' due to '(!env.GITHUB_TOKEN)'
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://172.24.80.224:49775/ CI:true GITHUB_ACTION:1 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_REF:refs/heads/debug-act-bug5 GITHUB_REF_NAME:debug-act-bug5 GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:jenseng/dynamic-uses GITHUB_REPOSITORY_OWNER:jenseng GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:26b632fc2f4f001e4e955fa13a7cafcbd01e9897 GITHUB_TOKEN:*** GITHUB_WORKFLOW:test GITHUB_WORKSPACE:/Users/jonj/projects/dynamic-uses ImageOS:ubuntu20 RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:]
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] evaluating expression 'env.GITHUB_TOKEN'
[test/test] [DEBUG] expression 'env.GITHUB_TOKEN' evaluated to '%!t(string=***)'
[test/test] ⭐ Run Main echo "::error::GITHUB_TOKEN is set but shouldn't be!"
exit 1
[test/test] [DEBUG] Writing entry to tarball workflow/outputcmd.txt len:0
[test/test] [DEBUG] Writing entry to tarball workflow/statecmd.txt len:0
[test/test] [DEBUG] Writing entry to tarball workflow/pathcmd.txt len:0
[test/test] [DEBUG] Writing entry to tarball workflow/envs.txt len:0
[test/test] [DEBUG] Writing entry to tarball workflow/SUMMARY.md len:0
[test/test] [DEBUG] Extracting content to '/var/run/act'
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] Wrote command

echo "::error::GITHUB_TOKEN is set but shouldn't be!"
exit 1


 to 'workflow/1'
[test/test] [DEBUG] Writing entry to tarball workflow/1 len:63
[test/test] [DEBUG] Extracting content to '/var/run/act'
[test/test]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir=
[test/test] [DEBUG] Exec command '[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1]'
[test/test] [DEBUG] Working directory '/Users/jonj/projects/dynamic-uses'
[test/test]   ❗  ::error::GITHUB_TOKEN is set but shouldn't be!
[test/test]   ❌  Failure - Main echo "::error::GITHUB_TOKEN is set but shouldn't be!"
exit 1
[test/test] exitcode '1': failure
[test/test] 🏁  Job failed
[test/test] [DEBUG] Loading revision from git directory
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
[test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897'
[test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5
[test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897
Error: Job 'test' failed

Additional information

No response

Originally created by @jenseng on GitHub (Nov 8, 2023). Original GitHub issue: https://github.com/nektos/act/issues/2081 ### Bug report info ```plain text act version: 0.2.53 GOOS: darwin GOARCH: arm64 NumCPU: 12 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock $HOME/.docker/run/docker.sock Config files: /Users/jonj/.actrc: -P ubuntu-latest=node:16-buster-slim -P ubuntu-22.04=node:16-bullseye-slim -P ubuntu-20.04=node:16-buster-slim -P ubuntu-18.04=node:16-buster-slim Build info: Go version: go1.21.3 Module path: command-line-arguments Main version: Main path: Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -X main.version=0.2.53 DefaultGODEBUG: panicnil=1 CGO_ENABLED: 1 CGO_CFLAGS: CGO_CPPFLAGS: CGO_CXXFLAGS: CGO_LDFLAGS: GOARCH: arm64 GOOS: darwin Docker Engine: Engine version: 24.0.6 Engine runtime: runc Cgroup version: 2 Cgroup driver: cgroupfs Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Docker Desktop OS type: linux OS version: OS arch: aarch64 OS kernel: 6.4.16-linuxkit OS CPU: 12 OS memory: 7844 MB Security options: name=seccomp,profile=unconfined name=cgroupns ``` ### Command used with act ```sh act -s GITHUB_TOKEN=thisisasecret -vW .github/workflows/sample.yml ``` ### Describe issue If you set a `GITHUB_TOKEN` secret, a `GITHUB_TOKEN` env variable will automatically be set in jobs, even if you don't explicitly specify it in the `env`. This is inconsistent with actual GitHub Actions workflows; if you want a `GITHUB_TOKEN` env variable, you need to explicitly set it via `env`. This is problematic since it can result in poorly written jobs "working" locally with act but then breaking when pushed to GitHub. I've run into this multiple times when I've written a job that uses the `gh` CLI but forgotten to actually set the `GITHUB_TOKEN` in `env`; my local test works, but then the real run fails 🫠 ### Link to GitHub repository https://github.com/jenseng/dynamic-uses/actions/runs/6801630930/job/18492924811 ### Workflow content ```yml name: test on: push jobs: test: runs-on: ubuntu-latest steps: - run: echo "GITHUB_TOKEN is NOT set 😅" if: (!env.GITHUB_TOKEN) - run: | echo "::error::GITHUB_TOKEN is set but shouldn't be!" exit 1 if: env.GITHUB_TOKEN ``` ### Relevant log output ```sh WARN ⚠ You are using Apple M-series chip and you have not specified container architecture, you might encounter issues while running act. If so, try running it with '--container-architecture linux/amd64'. ⚠ DEBU[0000] Loading environment from /Users/jonj/projects/dynamic-uses/.env DEBU[0000] Loading action inputs from /Users/jonj/projects/dynamic-uses/.input DEBU[0000] Loading secrets from /Users/jonj/projects/dynamic-uses/.secrets DEBU[0000] Loading vars from /Users/jonj/projects/dynamic-uses/.vars DEBU[0000] Evaluated matrix inclusions: map[] DEBU[0000] Loading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml' DEBU[0000] Reading workflow '/Users/jonj/projects/dynamic-uses/.github/workflows/sample.yml' DEBU[0000] Conditional GET for notices etag=b769c9d4-c638-4197-b343-39d63c669434 DEBU[0000] Preparing plan with all jobs DEBU[0000] Using the only detected workflow event: push DEBU[0000] Planning jobs for event: push DEBU[0000] gc: 2023-11-08 10:12:08.04153 -0700 MST m=+0.004306626 module=artifactcache DEBU[0000] Plan Stages: [0x14000394330] DEBU[0000] Stages Runs: [test] DEBU[0000] Job.Name: test DEBU[0000] Job.RawNeeds: {0 0 <nil> [] 0 0} DEBU[0000] Job.RawRunsOn: {8 0 !!str ubuntu-latest <nil> [] 5 14} DEBU[0000] Job.Env: {0 0 <nil> [] 0 0} DEBU[0000] Job.If: {0 0 success() <nil> [] 0 0} DEBU[0000] Job.Steps: echo "GITHUB_TOKEN is NOT set 😅" DEBU[0000] Job.Steps: echo "::error::GITHUB_TOKEN is set but shouldn't be!" exit 1 DEBU[0000] Job.TimeoutMinutes: DEBU[0000] Job.Services: map[] DEBU[0000] Job.Strategy: <nil> DEBU[0000] Job.RawContainer: {0 0 <nil> [] 0 0} DEBU[0000] Job.Defaults.Run.Shell: DEBU[0000] Job.Defaults.Run.WorkingDirectory: DEBU[0000] Job.Outputs: map[] DEBU[0000] Job.Uses: DEBU[0000] Job.With: map[] DEBU[0000] Job.Result: DEBU[0000] Empty Strategy, matrixes=[map[]] DEBU[0000] Job Matrices: [map[]] DEBU[0000] Runner Matrices: map[] DEBU[0000] Final matrix after applying user inclusions '[map[]]' DEBU[0000] Loading revision from git directory DEBU[0000] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 DEBU[0000] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' DEBU[0000] using github ref: refs/heads/debug-act-bug5 DEBU[0000] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 DEBU[0000] Detected CPUs: 12 [test/test] [DEBUG] evaluating expression 'success()' [test/test] [DEBUG] expression 'success()' evaluated to 'true' [test/test] 🚀 Start image=node:16-buster-slim INFO[0000] Parallel tasks (0) below minimum, setting to 1 [test/test] 🐳 docker pull image=node:16-buster-slim platform= username= forcePull=true [test/test] [DEBUG] 🐳 docker pull node:16-buster-slim [test/test] [DEBUG] pulling image 'docker.io/library/node:16-buster-slim' () DEBU[0000] Saving notices etag=b769c9d4-c638-4197-b343-39d63c669434 DEBU[0000] No new notices [test/test] [DEBUG] Pulling from library/node :: 16-buster-slim [test/test] [DEBUG] Digest: sha256:3ebf2875c188d22939c6ab080cfb1a4a6248cc86bae600ea8e2326aa03acdb8f :: [test/test] [DEBUG] Status: Image is up to date for node:16-buster-slim :: INFO[0001] Parallel tasks (0) below minimum, setting to 1 [test/test] 🐳 docker create image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [test/test] [DEBUG] Common container.Config ==> &{Hostname: Domainname: User: AttachStdin:false AttachStdout:false AttachStderr:false ExposedPorts:map[] Tty:true OpenStdin:false StdinOnce:false Env:[RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8] Cmd:[] Healthcheck:<nil> ArgsEscaped:false Image:node:16-buster-slim Volumes:map[] WorkingDir:/Users/jonj/projects/dynamic-uses Entrypoint:[] NetworkDisabled:false MacAddress: OnBuild:[] Labels:map[] StopSignal: StopTimeout:<nil> Shell:[]} [test/test] [DEBUG] Common container.HostConfig ==> &{Binds:[/var/run/docker.sock:/var/run/docker.sock] ContainerIDFile: LogConfig:{Type: Config:map[]} NetworkMode:host PortBindings:map[] RestartPolicy:{Name: MaximumRetryCount:0} AutoRemove:false VolumeDriver: VolumesFrom:[] ConsoleSize:[0 0] Annotations:map[] CapAdd:[] CapDrop:[] CgroupnsMode: DNS:[] DNSOptions:[] DNSSearch:[] ExtraHosts:[] GroupAdd:[] IpcMode: Cgroup: Links:[] OomScoreAdj:0 PidMode: Privileged:false PublishAllPorts:false ReadonlyRootfs:false SecurityOpt:[] StorageOpt:map[] Tmpfs:map[] UTSMode: UsernsMode: ShmSize:0 Sysctls:map[] Runtime: Isolation: Resources:{CPUShares:0 Memory:0 NanoCPUs:0 CgroupParent: BlkioWeight:0 BlkioWeightDevice:[] BlkioDeviceReadBps:[] BlkioDeviceWriteBps:[] BlkioDeviceReadIOps:[] BlkioDeviceWriteIOps:[] CPUPeriod:0 CPUQuota:0 CPURealtimePeriod:0 CPURealtimeRuntime:0 CpusetCpus: CpusetMems: Devices:[] DeviceCgroupRules:[] DeviceRequests:[] KernelMemory:0 KernelMemoryTCP:0 MemoryReservation:0 MemorySwap:0 MemorySwappiness:<nil> OomKillDisable:<nil> PidsLimit:<nil> Ulimits:[] CPUCount:0 CPUPercent:0 IOMaximumIOps:0 IOMaximumBandwidth:0} Mounts:[{Type:volume Source:act-toolcache Target:/toolcache ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b-env Target:/var/run/act ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>} {Type:volume Source:act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b Target:/Users/jonj/projects/dynamic-uses ReadOnly:false Consistency: BindOptions:<nil> VolumeOptions:<nil> TmpfsOptions:<nil> ClusterOptions:<nil>}] MaskedPaths:[] ReadonlyPaths:[] Init:<nil>} [test/test] [DEBUG] input.NetworkAliases ==> [test] [test/test] [DEBUG] not a use defined config?? [test/test] [DEBUG] Created container name=act-test-test-24f46b2e65c2fc9b49cf0e305f210649cb0a45d5b5dc0a1380eb443748b7420b id=1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9 from image node:16-buster-slim (platform: ) [test/test] [DEBUG] ENV ==> [RUNNER_TOOL_CACHE=/opt/hostedtoolcache RUNNER_OS=Linux RUNNER_ARCH=ARM64 RUNNER_TEMP=/tmp LANG=C.UTF-8] [test/test] 🐳 docker run image=node:16-buster-slim platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host" [test/test] [DEBUG] Starting container: 1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9 [test/test] [DEBUG] Started container: 1e288b3bcd8b78297aa2727fda554700c278136b7111739e398969ebf98f9bf9 [test/test] [DEBUG] Writing entry to tarball workflow/event.json len:2 [test/test] [DEBUG] Writing entry to tarball workflow/envs.txt len:0 [test/test] [DEBUG] Extracting content to '/var/run/act/' [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://172.24.80.224:49775/ CI:true GITHUB_ACTION:0 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_REF:refs/heads/debug-act-bug5 GITHUB_REF_NAME:debug-act-bug5 GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:jenseng/dynamic-uses GITHUB_REPOSITORY_OWNER:jenseng GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:26b632fc2f4f001e4e955fa13a7cafcbd01e9897 GITHUB_TOKEN:*** GITHUB_WORKFLOW:test GITHUB_WORKSPACE:/Users/jonj/projects/dynamic-uses ImageOS:ubuntu20 RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:] [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] evaluating expression '(!env.GITHUB_TOKEN)' [test/test] [DEBUG] expression '(!env.GITHUB_TOKEN)' evaluated to 'false' [test/test] [DEBUG] Skipping step 'echo "GITHUB_TOKEN is NOT set 😅"' due to '(!env.GITHUB_TOKEN)' [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] setupEnv => map[ACT:true ACTIONS_CACHE_URL:http://172.24.80.224:49775/ CI:true GITHUB_ACTION:1 GITHUB_ACTIONS:true GITHUB_ACTION_PATH: GITHUB_ACTION_REF: GITHUB_ACTION_REPOSITORY: GITHUB_ACTOR:nektos/act GITHUB_API_URL:https://api.github.com GITHUB_BASE_REF: GITHUB_EVENT_NAME:push GITHUB_EVENT_PATH:/var/run/act/workflow/event.json GITHUB_GRAPHQL_URL:https://api.github.com/graphql GITHUB_HEAD_REF: GITHUB_JOB:test GITHUB_REF:refs/heads/debug-act-bug5 GITHUB_REF_NAME:debug-act-bug5 GITHUB_REF_TYPE:branch GITHUB_REPOSITORY:jenseng/dynamic-uses GITHUB_REPOSITORY_OWNER:jenseng GITHUB_RETENTION_DAYS:0 GITHUB_RUN_ID:1 GITHUB_RUN_NUMBER:1 GITHUB_SERVER_URL:https://github.com GITHUB_SHA:26b632fc2f4f001e4e955fa13a7cafcbd01e9897 GITHUB_TOKEN:*** GITHUB_WORKFLOW:test GITHUB_WORKSPACE:/Users/jonj/projects/dynamic-uses ImageOS:ubuntu20 RUNNER_PERFLOG:/dev/null RUNNER_TRACKING_ID:] [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] evaluating expression 'env.GITHUB_TOKEN' [test/test] [DEBUG] expression 'env.GITHUB_TOKEN' evaluated to '%!t(string=***)' [test/test] ⭐ Run Main echo "::error::GITHUB_TOKEN is set but shouldn't be!" exit 1 [test/test] [DEBUG] Writing entry to tarball workflow/outputcmd.txt len:0 [test/test] [DEBUG] Writing entry to tarball workflow/statecmd.txt len:0 [test/test] [DEBUG] Writing entry to tarball workflow/pathcmd.txt len:0 [test/test] [DEBUG] Writing entry to tarball workflow/envs.txt len:0 [test/test] [DEBUG] Writing entry to tarball workflow/SUMMARY.md len:0 [test/test] [DEBUG] Extracting content to '/var/run/act' [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] Wrote command echo "::error::GITHUB_TOKEN is set but shouldn't be!" exit 1 to 'workflow/1' [test/test] [DEBUG] Writing entry to tarball workflow/1 len:63 [test/test] [DEBUG] Extracting content to '/var/run/act' [test/test] 🐳 docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1] user= workdir= [test/test] [DEBUG] Exec command '[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/1]' [test/test] [DEBUG] Working directory '/Users/jonj/projects/dynamic-uses' [test/test] ❗ ::error::GITHUB_TOKEN is set but shouldn't be! [test/test] ❌ Failure - Main echo "::error::GITHUB_TOKEN is set but shouldn't be!" exit 1 [test/test] exitcode '1': failure [test/test] 🏁 Job failed [test/test] [DEBUG] Loading revision from git directory [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 [test/test] [DEBUG] HEAD points to '26b632fc2f4f001e4e955fa13a7cafcbd01e9897' [test/test] [DEBUG] using github ref: refs/heads/debug-act-bug5 [test/test] [DEBUG] Found revision: 26b632fc2f4f001e4e955fa13a7cafcbd01e9897 Error: Job 'test' failed ``` ### Additional information _No response_
kerem 2026-03-01 21:48:03 +03:00
  • closed this issue
  • added the
    kind/bug
    label
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#995
No description provided.