Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
prvg-sso opened this issue Oct 2, 2024 · 3 comments
Labels
kind/bug Something isn't working

Comments

@prvg-sso
Copy link

prvg-sso commented Oct 2, 2024

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 prvg-sso added the kind/bug Something isn't working label Oct 2, 2024
@prvg-sso
Copy link
Author

prvg-sso commented Oct 2, 2024

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

@ChristopherHX
Copy link
Contributor

ChristopherHX commented Oct 2, 2024

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

@prvg-sso
Copy link
Author

prvg-sso commented Oct 3, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants