the action doesn't not return data on closed pr
whiteRave1234 opened this issue · 5 comments
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/gh-get-current-pr@2.1.2
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
I had same issue similar like this, waiting for solution regarding this
I'm gonna check it out over this weekend and get back to you 👍🏼
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
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