[GH-ISSUE #2014] hashFiles does not resolve paths relative to GITHUB_WORKSPACE #964

Closed
opened 2026-03-01 21:47:47 +03:00 by kerem · 2 comments
Owner

Originally created by @notmgsk on GitHub (Sep 20, 2023).
Original GitHub issue: https://github.com/nektos/act/issues/2014

Bug report info

act version:            0.2.50
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 16
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
Config files:           
	/home/mgsk/.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
		--env ACTIONS_CACHE_URL=http://localhost:8080/
		--env ACTIONS_RUNTIME_URL=http://localhost:8080/
		--env ACTIONS_RUNTIME_TOKEN=foo
Build info:
	Go version:            go1.20.7
	Module path:           github.com/nektos/act
	Main version:          (devel)
	Main path:             github.com/nektos/act
	Main checksum:         
	Build settings:
		-buildmode:           exe
		-compiler:            gc
		-ldflags:             -s -w -X main.version=0.2.50 -X main.commit=80b0955303888742c3ab73af5758bb7b01f5f57c -X main.date=2023-09-01T02:12:50Z -X main.builtBy=goreleaser
		CGO_ENABLED:          0
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1
		vcs:                  git
		vcs.revision:         80b0955303888742c3ab73af5758bb7b01f5f57c
		vcs.time:             2023-09-01T02:12:28Z
		vcs.modified:         false
Docker Engine:
	Engine version:        20.10.21
	Engine runtime:        runc
	Cgroup version:        2
	Cgroup driver:         systemd
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    Ubuntu 23.04
	OS type:               linux
	OS version:            23.04
	OS arch:               x86_64
	OS kernel:             6.2.0-32-generic
	OS CPU:                16
	OS memory:             64232 MB
	Security options:
		name=apparmor
		name=seccomp,profile=default
		name=cgroupns

Command used with act

`./bin/act`

Describe issue

The github actions docs state

The path is relative to the GITHUB_WORKSPACE directory
but that does not appear to be so when using act.

See the attached repo which

  • has a workflow that uses the checkout action with a path
  • has a file foo at its root
  • has a step which prints the value of hashFiles('foo')

In Github's own runner, this works fine: the file foo is found, hashed, and printed. When using act, the file is not found.

https://github.com/notmgsk/act-bug

Workflow content

name: Test

on:
  push:

jobs:
  test:
    name: Test
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2
        with:
          path: "test"

      - name: test
        env:
          THE_HASH: ${{ hashFiles('test/foo') }}
        run: echo $THE_HASH

Relevant log output

time="2023-09-20T19:19:40+01:00" level=debug msg="Loading environment from /home/mgsk/hackery/other/act-bug/.env"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading action inputs from /home/mgsk/hackery/other/act-bug/.input"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading secrets from /home/mgsk/hackery/other/act-bug/.secrets"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading vars from /home/mgsk/hackery/other/act-bug/.vars"
time="2023-09-20T19:19:40+01:00" level=debug msg="Conditional GET for notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0"
time="2023-09-20T19:19:40+01:00" level=debug msg="Evaluated matrix inclusions: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows from '/home/mgsk/hackery/other/act-bug/.github/workflows'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows recursively"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found workflow 'test.yml' in '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Reading workflow '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Preparing plan with all jobs"
time="2023-09-20T19:19:40+01:00" level=debug msg="Using the only detected workflow event: push"
time="2023-09-20T19:19:40+01:00" level=debug msg="Planning jobs for event: push"
time="2023-09-20T19:19:40+01:00" level=debug msg="Plan Stages: [0xc0004ad3b0]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Stages Runs: [Test]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Name: Test"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawNeeds: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawRunsOn: {8 0 !!str ubuntu-latest  <nil> []    9 14}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Env: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.If: {0 0  success()  <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: actions/checkout@v2"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: test"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.TimeoutMinutes: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Services: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Strategy: <nil>"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawContainer: {0 0    <nil> []    0 0}"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.Shell: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.WorkingDirectory: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Outputs: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Uses: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.With: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Result: "
time="2023-09-20T19:19:40+01:00" level=debug msg="Empty Strategy, matrixes=[map[]]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Job Matrices: [map[]]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Runner Matrices: map[]"
time="2023-09-20T19:19:40+01:00" level=debug msg="Final matrix after applying user inclusions '[map[]]'"
time="2023-09-20T19:19:40+01:00" level=debug msg="Loading revision from git directory"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a"
time="2023-09-20T19:19:40+01:00" level=debug msg="HEAD points to '7637d68d81a405033ac72362bec5afffdb10776a'"
time="2023-09-20T19:19:40+01:00" level=debug msg="using github ref: refs/heads/master"
time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a"
time="2023-09-20T19:19:40+01:00" level=debug msg="Detected CPUs: 16"
time="2023-09-20T19:19:41+01:00" level=debug msg="Saving notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0"
time="2023-09-20T19:19:41+01:00" level=debug msg="No new notices"

Additional information

No response

Originally created by @notmgsk on GitHub (Sep 20, 2023). Original GitHub issue: https://github.com/nektos/act/issues/2014 ### Bug report info ```plain text act version: 0.2.50 GOOS: linux GOARCH: amd64 NumCPU: 16 Docker host: DOCKER_HOST environment variable is not set Sockets found: /var/run/docker.sock Config files: /home/mgsk/.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 --env ACTIONS_CACHE_URL=http://localhost:8080/ --env ACTIONS_RUNTIME_URL=http://localhost:8080/ --env ACTIONS_RUNTIME_TOKEN=foo Build info: Go version: go1.20.7 Module path: github.com/nektos/act Main version: (devel) Main path: github.com/nektos/act Main checksum: Build settings: -buildmode: exe -compiler: gc -ldflags: -s -w -X main.version=0.2.50 -X main.commit=80b0955303888742c3ab73af5758bb7b01f5f57c -X main.date=2023-09-01T02:12:50Z -X main.builtBy=goreleaser CGO_ENABLED: 0 GOARCH: amd64 GOOS: linux GOAMD64: v1 vcs: git vcs.revision: 80b0955303888742c3ab73af5758bb7b01f5f57c vcs.time: 2023-09-01T02:12:28Z vcs.modified: false Docker Engine: Engine version: 20.10.21 Engine runtime: runc Cgroup version: 2 Cgroup driver: systemd Storage driver: overlay2 Registry URI: https://index.docker.io/v1/ OS: Ubuntu 23.04 OS type: linux OS version: 23.04 OS arch: x86_64 OS kernel: 6.2.0-32-generic OS CPU: 16 OS memory: 64232 MB Security options: name=apparmor name=seccomp,profile=default name=cgroupns ``` ### Command used with act ```sh `./bin/act` ``` ### Describe issue The [github actions docs](https://docs.github.com/en/actions/learn-github-actions/expressions#hashfiles) state > The path is relative to the GITHUB_WORKSPACE directory but that does not appear to be so when using `act`. See the attached repo which * has a workflow that uses the `checkout` action with a `path` * has a file `foo` at its root * has a step which prints the value of `hashFiles('foo')` In Github's own runner, this [works fine](https://github.com/notmgsk/act-bug/actions/runs/6252454302/job/16975767156): the file `foo` is found, hashed, and printed. When using `act`, the file is not found. ### Link to GitHub repository https://github.com/notmgsk/act-bug ### Workflow content ```yml name: Test on: push: jobs: test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: path: "test" - name: test env: THE_HASH: ${{ hashFiles('test/foo') }} run: echo $THE_HASH ``` ### Relevant log output ```sh time="2023-09-20T19:19:40+01:00" level=debug msg="Loading environment from /home/mgsk/hackery/other/act-bug/.env" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading action inputs from /home/mgsk/hackery/other/act-bug/.input" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading secrets from /home/mgsk/hackery/other/act-bug/.secrets" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading vars from /home/mgsk/hackery/other/act-bug/.vars" time="2023-09-20T19:19:40+01:00" level=debug msg="Conditional GET for notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0" time="2023-09-20T19:19:40+01:00" level=debug msg="Evaluated matrix inclusions: map[]" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows from '/home/mgsk/hackery/other/act-bug/.github/workflows'" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading workflows recursively" time="2023-09-20T19:19:40+01:00" level=debug msg="Found workflow 'test.yml' in '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'" time="2023-09-20T19:19:40+01:00" level=debug msg="Reading workflow '/home/mgsk/hackery/other/act-bug/.github/workflows/test.yml'" time="2023-09-20T19:19:40+01:00" level=debug msg="Preparing plan with all jobs" time="2023-09-20T19:19:40+01:00" level=debug msg="Using the only detected workflow event: push" time="2023-09-20T19:19:40+01:00" level=debug msg="Planning jobs for event: push" time="2023-09-20T19:19:40+01:00" level=debug msg="Plan Stages: [0xc0004ad3b0]" time="2023-09-20T19:19:40+01:00" level=debug msg="Stages Runs: [Test]" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Name: Test" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawNeeds: {0 0 <nil> [] 0 0}" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawRunsOn: {8 0 !!str ubuntu-latest <nil> [] 9 14}" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Env: {0 0 <nil> [] 0 0}" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.If: {0 0 success() <nil> [] 0 0}" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: actions/checkout@v2" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Steps: test" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.TimeoutMinutes: " time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Services: map[]" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Strategy: <nil>" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.RawContainer: {0 0 <nil> [] 0 0}" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.Shell: " time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Defaults.Run.WorkingDirectory: " time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Outputs: map[]" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Uses: " time="2023-09-20T19:19:40+01:00" level=debug msg="Job.With: map[]" time="2023-09-20T19:19:40+01:00" level=debug msg="Job.Result: " time="2023-09-20T19:19:40+01:00" level=debug msg="Empty Strategy, matrixes=[map[]]" time="2023-09-20T19:19:40+01:00" level=debug msg="Job Matrices: [map[]]" time="2023-09-20T19:19:40+01:00" level=debug msg="Runner Matrices: map[]" time="2023-09-20T19:19:40+01:00" level=debug msg="Final matrix after applying user inclusions '[map[]]'" time="2023-09-20T19:19:40+01:00" level=debug msg="Loading revision from git directory" time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a" time="2023-09-20T19:19:40+01:00" level=debug msg="HEAD points to '7637d68d81a405033ac72362bec5afffdb10776a'" time="2023-09-20T19:19:40+01:00" level=debug msg="using github ref: refs/heads/master" time="2023-09-20T19:19:40+01:00" level=debug msg="Found revision: 7637d68d81a405033ac72362bec5afffdb10776a" time="2023-09-20T19:19:40+01:00" level=debug msg="Detected CPUs: 16" time="2023-09-20T19:19:41+01:00" level=debug msg="Saving notices etag=80e90080-cbc3-41d4-b5f6-18ef0d15e0d0" time="2023-09-20T19:19:41+01:00" level=debug msg="No new notices" ``` ### Additional information _No response_
kerem 2026-03-01 21:47:47 +03:00
  • closed this issue
  • added the
    kind/bug
    label
Author
Owner

@ChristopherHX commented on GitHub (Sep 20, 2023):

Yeah I wanted to fix it via https://github.com/nektos/act/pull/1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container.

hashfiles currently operates relative to the checked out repository on the caller side where act is run.

<!-- gh-comment-id:1728351279 --> @ChristopherHX commented on GitHub (Sep 20, 2023): Yeah I wanted to fix it via https://github.com/nektos/act/pull/1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container. hashfiles currently operates relative to the checked out repository on the caller side where act is run.
Author
Owner

@notmgsk commented on GitHub (Sep 21, 2023):

Yeah I wanted to fix it via #1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container.

hashfiles currently operates relative to the checked out repository on the caller side where act is run.

Thanks for the info, @ChristopherHX. I hope you're able to get your fix merged.

In the meantime, I side-stepped the issue by doing hashFiles('**/<file>') where <file> is unique in the repo.

<!-- gh-comment-id:1729804576 --> @notmgsk commented on GitHub (Sep 21, 2023): > Yeah I wanted to fix it via #1940 (part of my fork of act for github-act-runner), but merging is blocked, by running hashfiles inside the container. > > hashfiles currently operates relative to the checked out repository on the caller side where act is run. Thanks for the info, @ChristopherHX. I hope you're able to get your fix merged. In the meantime, I side-stepped the issue by doing `hashFiles('**/<file>')` where `<file>` is unique in the repo.
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#964
No description provided.