Skip to content

fix: handle pull_request_review events in fromFork() (#1038) - #1039

Open
aditya226-sharma wants to merge 2 commits into
canonical:mainfrom
aditya226-sharma:fix/fromFork-pull-request-review
Open

fix: handle pull_request_review events in fromFork() (#1038)#1039
aditya226-sharma wants to merge 2 commits into
canonical:mainfrom
aditya226-sharma:fix/fromFork-pull-request-review

Conversation

@aditya226-sharma

Copy link
Copy Markdown

Summary

Extends fromFork() to also detect fork PRs when the workflow is triggered by pull_request_review events, preventing image upload failures on PR approvals.

Changes

  • Added pull_request_review to the accepted event names in fromFork()
  • The function now correctly identifies fork PRs for both pull_request and pull_request_review events

Why

When the workflow is triggered by pull_request_review (e.g., on approval), context.eventName is 'pull_request_review' instead of 'pull_request'. The old code returned false for any non-pull_request event, causing operator-workflows to default to registry (ghcr.io). In GitHub Actions, standard GITHUB_TOKEN credentials in workflow runs triggered by PR review events do not have permissions to write/create packages, resulting in denied: installation not allowed to Create organization package errors.

Closes #1038

@aditya226-sharma
aditya226-sharma requested a review from a team as a code owner August 19, 2026 19:22
Prettier required the multi-line if condition to be wrapped, which was
failing the lint/check-dist CI job. Also simplified fromFork() by
removing the now-redundant duplicate return branch for
pull_request_review, since both branches used identical logic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

Test results for commit e5e9669

Test coverage for e5e9669

Name           Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------
src/charm.py       8      8      0      0     0%   8-25
----------------------------------------------------------
TOTAL              8      8      0      0     0%

Static code analysis report

Run started:2026-08-21 13:50:36.796918+00:00

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 56
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@github-actions

Copy link
Copy Markdown
Contributor

Test results for commit e5e9669

Test coverage for e5e9669

Name           Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------
src/charm.py       8      8      0      0     0%   8-25
----------------------------------------------------------
TOTAL              8      8      0      0     0%

Static code analysis report

Run started:2026-08-21 13:50:33.961423+00:00

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 56
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@github-actions

Copy link
Copy Markdown
Contributor

Test results for commit e5e9669

Test coverage for e5e9669

Name           Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------
src/charm.py       8      8      0      0     0%   8-25
----------------------------------------------------------
TOTAL              8      8      0      0     0%

Static code analysis report

Run started:2026-08-21 14:14:23.677452+00:00

Test results:
  No issues identified.

Code scanned:
  Total lines of code: 56
  Total lines skipped (#nosec): 0
  Total potential issues skipped due to specifically being disabled (e.g., #nosec BXXX): 0

Run metrics:
  Total issues (by severity):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
  Total issues (by confidence):
  	Undefined: 0
  	Low: 0
  	Medium: 0
  	High: 0
Files skipped (0):

@seb4stien

Copy link
Copy Markdown
Contributor

@aditya226-sharma unfortunately we cannot merge an unsigned commit. Is it fine for you if we close this PR and open a separate one under our name? If not, can you please sign your commit?

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.

integration_test fails on pull_request_review events due to unauthorized GHCR package push

3 participants