Skip to content

Re-implement get-current-pr action, add authentication.#33

Merged
JackPGreen merged 4 commits intohazelcast:masterfrom
JackPGreen:reimplement-gh-get-current-pr
Dec 11, 2025
Merged

Re-implement get-current-pr action, add authentication.#33
JackPGreen merged 4 commits intohazelcast:masterfrom
JackPGreen:reimplement-gh-get-current-pr

Conversation

@JackPGreen
Copy link
Copy Markdown
Contributor

@JackPGreen JackPGreen commented Dec 9, 2025

Despite extensive testing for #31, the action fails with a cryptic Not Found when executed for real.

After further investigation, this could be reproduced within a PR from a fork only, which was not previously tested.

The root cause is that the "implicit" token supplied to the workflow does not have permissions to query metadata outside of the repo it's being run from. Instead, we should use the supplied token that we already use for the "main" backporting operation.

After discussion as part of #32, it was also suggested to avoid using the token with a third-party action when a first-party solution was available (with some mangling).

Changes:

  • add token to get-current-pr step
  • replace 8BitJonny/gh-get-current-pr with our own implementation
  • fix a syntax error when creating backport branches

Successful execution from a forked PR, and resultant backport.

Closes: #32

@JackPGreen JackPGreen self-assigned this Dec 9, 2025
@JackPGreen JackPGreen force-pushed the reimplement-gh-get-current-pr branch 2 times, most recently from d4b584f to 7e76110 Compare December 10, 2025 12:22
@JackPGreen JackPGreen force-pushed the reimplement-gh-get-current-pr branch from 7e76110 to 0248e4a Compare December 10, 2025 19:05
fi
done

echo "number=$(jq --raw-output '.[0].number' <<< "${response}")" >> ${GITHUB_ENV}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. some comments will be helpful as to why we have to check for both events?
  2. do both events always trigger and in which order?
  3. Is ${GITHUB_SHA} available in both cases? wondering if the code can be combined?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. some comments will be helpful as to why we have to check for both events?

0f6359d

  1. do both events always trigger and in which order?

They are exclusive, we watch for any of them:
https://github.com/hazelcast/hazelcast-mono/blob/a6f00489d8e3f6170656612f2d9e5408ff33726d/.github/workflows/backport.yml#L2-L8

  1. Is ${GITHUB_SHA} available in both cases?

Yes, it's always part of the GitHub context.

wondering if the code can be combined?

I don't think so, or at least not in a way that makes it any better.

# Immediately after a commit, sometimes the API returns no results, so poll for valid values
while :
do
response=$(gh api \
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use https://cli.github.com/manual/gh_pr_list?
there is also ability to search

Not sure if any these is better or whether it can avoid the loop

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could use https://cli.github.com/manual/gh_pr_list? there is also ability to search

Not sure if any these is better or whether it can avoid the loop

I'd imagine under-the-hood it uses the same API.
The loop is working around an issue on the GitHub side, I guess I could raise a ticket but that doesn't help us now.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add link to the issue pls?
perhaps something to revisit in the future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add link to the issue pls? perhaps something to revisit in the future.

https://support.github.com/ticket/personal/0/3953542

@JackPGreen JackPGreen requested a review from nishaatr December 11, 2025 10:50
@JackPGreen JackPGreen merged commit b735871 into hazelcast:master Dec 11, 2025
3 checks passed
@JackPGreen JackPGreen deleted the reimplement-gh-get-current-pr branch December 11, 2025 12:46
JackPGreen added a commit to JackPGreen/backport that referenced this pull request Dec 12, 2025
…of `backport` action

Raised after [PR feedback](hazelcast#33 (comment)) in consultation with GitHub support who provided further clarification.
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

Successfully merging this pull request may close these issues.

2 participants