act icon indicating copy to clipboard operation
act copied to clipboard

pull_request events are registered as push events when having multiple workflows that trigger on both pull and push

Open prvg-sso opened this issue 1 year ago • 3 comments

Bug report info

act version:            0.2.67
GOOS:                   linux
GOARCH:                 amd64
NumCPU:                 4
Docker host:            DOCKER_HOST environment variable is not set
Sockets found:
	/var/run/docker.sock
Config files:           
	/home/admin/.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.21.13
	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.67 -X main.commit=f75a2d8b38cc3b929ab652c0994d6d33f6584ed9 -X main.date=2024-09-10T18:17:24Z -X main.builtBy=goreleaser
		CGO_ENABLED:          0
		GOARCH:               amd64
		GOOS:                 linux
		GOAMD64:              v1
		vcs:                  git
		vcs.revision:         f75a2d8b38cc3b929ab652c0994d6d33f6584ed9
		vcs.time:             2024-09-10T18:17:07Z
		vcs.modified:         false
Docker Engine:
	Engine version:        20.10.17
	Engine runtime:        runc
	Cgroup version:        1
	Cgroup driver:         cgroupfs
	Storage driver:        overlay2
	Registry URI:          https://index.docker.io/v1/
	OS:                    CentOS Linux 7 (Core)
	OS type:               linux
	OS version:            7
	OS arch:               x86_64
	OS kernel:             3.10.0-1160.71.1.el7.x86_64
	OS CPU:                4
	OS memory:             15884 MB
	Security options:
		name=seccomp,profile=default

Command used with act

act --bind .github/workflow_tests/event_pr_open_simple.json

Describe issue

I have two workflows (test-push-workflow.yml, test-pull_request-workflow.yml), one triggers on push events and the other trigger on pull_request events. When providing a sample pull_request event json, the workflow that triggers on the push event is executed, NOT the one that triggers on pull_request. However, If I remove the test-push-workflow.yml from the .github/workflows dir, then test-pull_request-workflow.yml is triggered with the correct pull_request event!.

Link to GitHub repository

No response

Workflow content

name: test pull_request workflow
on:
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
    - 'main'

jobs:
  debug_input_:
    runs-on: 'ubuntu-latest'
    steps:
      - name: Check the inputss
        run: echo "The event that triggered this workflow is ${{ github.event_name }}"

Relevant log output

[admin@localhost test-github-events]$ act --bind -e event_pr_open_simple.json --secret-file .env-dev
INFO[0000] Using docker host 'unix:///var/run/docker.sock', and daemon socket 'unix:///var/run/docker.sock' 
WARN[0000] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found 
WARN[0000] unable to get git ref: reference not found   
WARN[0000] unable to get git revision: reference not found 
[test push workflow/debug_input__] 🚀  Start image=catthehacker/ubuntu:act-latest
[test push workflow/debug_input__]   🐳  docker pull image=catthehacker/ubuntu:act-latest platform= username= forcePull=true
[test push workflow/debug_input__]   🐳  docker create image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[test push workflow/debug_input__]   🐳  docker run image=catthehacker/ubuntu:act-latest platform= entrypoint=["tail" "-f" "/dev/null"] cmd=[] network="host"
[test push workflow/debug_input__]   🐳  docker exec cmd=[node --no-warnings -e console.log(process.execPath)] user= workdir=
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] ⭐ Run Main Check the inputss
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found
[test push workflow/debug_input__]   🐳  docker exec cmd=[bash --noprofile --norc -e -o pipefail /var/run/act/workflow/0] user= workdir=
| The event that triggered this workflow is push
[test push workflow/debug_input__]   ✅  Success - Main Check the inputss
[test push workflow/debug_input__] Cleaning up container for job debug_input__
[test push workflow/debug_input__] 🏁  Job succeeded
[test push workflow/debug_input__] unable to get git repo (githubInstance: github.com; remoteName: origin, repoPath: /home/admin/Projects/test-github-events): remote not found
[test push workflow/debug_input__] unable to get git ref: reference not found
[test push workflow/debug_input__] unable to get git revision: reference not found

Additional information

event_pr_open_simple.json:

{
  "pull_request": {
    "head": {
      "ref": "sample-head-ref"
    },
    "base": {
      "ref": "sample-base-ref"
    }
  }
}

.github/workflows/test-push-workflow.yml

name: test push workflow
on:
  push:

jobs:
  debug_input__:
    runs-on: 'ubuntu-latest'
    steps:
      - name: Check the inputss
        run: echo "The event that triggered this workflow is ${{ github.event_name }}"

prvg-sso avatar Oct 02 '24 12:10 prvg-sso

the pull_request also doesn't work if there is a reusable workflow in .github/workflows/ dir, which is the real problem from me..

prvg-sso avatar Oct 02 '24 13:10 prvg-sso

This is an user error, it's impossible to reliable reverse engineer a webhook payload to an event_name. The auto detection is super basic and were initially not present. Intially where act aliased to act push, external contributors changed that to do trivial auto detection.

You are expected to run act pull_request --bind -e event_pr_open_simple.json --secret-file .env-dev

More Details:

  • pull_request_target shares the exact same event payload
  • pull_request_review has a pull_request property as well

This doesn't fall into the capacity I allocate for act enhancements that are nice to have

ChristopherHX avatar Oct 02 '24 22:10 ChristopherHX

aha, I see now it's stated quite clearly in the usage guide :). I thought the event could be detected from the content of the payload, but apparently not. Thanks for helping out!.

On Thu, 3 Oct 2024 at 00:18, ChristopherHX @.***> wrote:

This is an user error, it's impossible to reliable reverse engineer a webhook to a event_name. The auto detection is super basic and were initially not present. Intially where act aliased to act push, external contributors changed that to do trivial auto detection.

You are expected to run act pull_request --bind -e event_pr_open_simple.json --secret-file .env-dev

More Details:

  • pull_request_target shares the exact same event payload
  • pull_request_review has a pull_request property as well

This doesn't fall into the capacity I allocate for act enhancements that are nice to have

— Reply to this email directly, view it on GitHub https://github.com/nektos/act/issues/2478#issuecomment-2389785623, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZRHWGNBCY3IGE3E4YP3HQLZZRWMXAVCNFSM6AAAAABPHS3QC6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBZG44DKNRSGM . You are receiving this because you authored the thread.Message ID: @.***>

prvg-sso avatar Oct 03 '24 08:10 prvg-sso

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

github-actions[bot] avatar Apr 02 '25 00:04 github-actions[bot]