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

[error]Could not get pull request from context, exiting #13

Open
ravikp7 opened this issue Aug 31, 2020 · 8 comments
Open

[error]Could not get pull request from context, exiting #13

ravikp7 opened this issue Aug 31, 2020 · 8 comments

Comments

@ravikp7
Copy link

ravikp7 commented Aug 31, 2020

Hi @futuratrepadeira ! Thanks for this nifty action. I'm running into this issue.

My workflow looks like this:

- name: Changed Files Exporter
        id: get_file_changes
        uses: futuratrepadeira/[email protected]
        with:
          repo-token: ${{ secrets.GITHUB_TOKEN }}
          pattern: '^.*\.(ts|tsx)$'

Inspecting the code, I see it failing at the below line.

https://github.com/futuratrepadeira/changed-files/blob/ca328ebf8ca65f94258677cea8478f0094d76a8e/src/main.ts#L100

What could be a possible reason? Can I debug this locally?

Let me know if you need more debug info.

@duarten
Copy link
Member

duarten commented Aug 31, 2020

Hi @ravikp7, can you tell me on what event you're using the action? If you're not using it with pull_request events, then you have to specify the pr-number input.

@ravikp7
Copy link
Author

ravikp7 commented Aug 31, 2020

Hi @ravikp7, can you tell me on what event you're using the action? If you're not using it with pull_request events, then you have to specify the pr-number input.

I'm using it for the pull_request event

@ravikp7 ravikp7 closed this as completed Aug 31, 2020
@ravikp7 ravikp7 reopened this Aug 31, 2020
@duarten
Copy link
Member

duarten commented Aug 31, 2020

Hum.. that means accessing github.context.payload.pull_request resulted in an undefined value. The event is supposed to be stored in workflow/event.json/GITHUB_EVENT_PATH. Can your action be doing something that changes this?

Maybe this changed at some point, in which case I would recommend you try to run the action at v3.3.0. Unfortunately, there's no good way to debug this issue locally :/

@aheil
Copy link

aheil commented Oct 30, 2020

I see the same issue with v3.3.0 when using

     - name: Changed Files Exporter
        id: changed-files
        uses: futuratrepadeira/[email protected]
        with:
          repo-token: '${{ secrets.GITHUB_TOKEN }}'          
          pattern: '^.*\.(md|markdown)$'
          result-encoding: 'string'

The error I get looks like the following:

Run futuratrepadeira/[email protected]
  with:
    repo-token: ***
    pattern: ^.*\.(md|markdown)$
    result-encoding: string
Error: Could not get pull request from context, exiting

According to actions/checkout#136, I also tried to set

- uses: actions/checkout@v2
   with:
      ref: main

a the checkout step I run before.

@duarten
Copy link
Member

duarten commented Oct 31, 2020

@aheil is this something that happened once, or happens frequently? If the former, is anything special about that PR that you can think of?

@aheil
Copy link

aheil commented Oct 31, 2020

It happens frequently, I just tried another Action were I also have to pass the GITHUB_TOKEN.
Haven't changed anything else. I do not encounter any problems then.
If I can prived any further information, please let me know.

@roman-parkhunovskyi
Copy link

I get the error if my config includes the push:

on:
  pull_request:
    branches:
      - develop
    paths:
      - '**.py'
  push:
    paths:
      - '**.py'

No error for pull_request event. Would it be possible to add support for just pushes?

@duarten
Copy link
Member

duarten commented Nov 10, 2020

There's currently some support for push: you can specify the pr-number input. Adding native support for push shouldn't be too hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants