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

the action doesn't not return data on closed pr #165

Open
ghaniswara opened this issue Oct 13, 2022 · 5 comments
Open

the action doesn't not return data on closed pr #165

ghaniswara opened this issue Oct 13, 2022 · 5 comments
Labels
☢️ Bug enhancement New feature or request

Comments

@ghaniswara
Copy link

Subject of the issue

the action doesn't return api data on closed pr event

Your git environment

I have two github jobs one is to get the data using this repo action and one is a job that triggered when a pr is closed

jobs:
  get-pr:
    runs-on: ubuntu-latest
    outputs:
      PR: ${{steps.PR.outputs.pr}}
    steps:
      - name: Find Pull Request
        uses: 8BitJonny/[email protected]
        id: PR
        with:
          sha: ${{ github.event.pull_request.head.sha }}

closed_by_user:
    timeout-minutes: 30
    needs: get-pr
    if:  needs.get-pr.outputs.PR != '' && github.event.pull_request.merged == false && github.event.pull_request.closed
    runs-on: ubuntu-latest
    steps: 
         .....

Steps to reproduce

with the following if condition on the job

needs.get-pr.outputs.PR != '' && github.event.pull_request.merged == false && github.event.pull_request.closed

Expected behaviour

needs.get-pr.outputs.PR return json data , the job will triggered

Actual behaviour

the closed_by_user jobs didn't run because the needs.get-pr.outputs.PR didn't return any json data

when I removed the needs.get-pr.outputs.PR != '' the job is triggered, but got error since I need a data from the API, but the data is empty

@rhgenius
Copy link

I had same issue similar like this, waiting for solution regarding this

@8BitJonny
Copy link
Owner

I'm gonna check it out over this weekend and get back to you 👍🏼

@8BitJonny
Copy link
Owner

yep, can confirm the issue/bug. It's because Github's Api Endpoint completely ignores closed PRs and only cares about merged and open PRs.
Will think about possibilities and come back to this issue

@8BitJonny
Copy link
Owner

Still thinking about this one. But yeah, currently I'm leaning towards either just marking this as a limitation in the Readme for now.

This library purely functions and acts on the current commit sha and lets GithubApi do all the heavy lifting, whether we have a PR for that commit or not.
And if this library should extend its functionality to also find closed PRs, I currently can't think of a different way other than:

  • fetching all closed PRs for the current Repository (this should be done via Github Api)
  • then fetching all commits for all closed PRs and checking if we find our commit.

This is very much bruteforce and doesn't scale well with old repos (=many PRs) or big PRs(=many commits).
There is definitely some optimisations like not looking at all PRs that we're closed before the searched commit was created

But yeah, sadly I'm not able to tell you that this is something that will be resolved soonish

@8BitJonny
Copy link
Owner

Do any of you want to give the implementation a shot? @rhgenius @GagahGK

@8BitJonny 8BitJonny added the enhancement New feature or request label Oct 27, 2022
8BitJonny added a commit that referenced this issue Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☢️ Bug enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants