Skip to content

Fix changes requested action for fork branches#16148

Merged
amjithtitus09 merged 9 commits into
developfrom
copilot/fix-changes-requested-action-fork-branches
May 20, 2026
Merged

Fix changes requested action for fork branches#16148
amjithtitus09 merged 9 commits into
developfrom
copilot/fix-changes-requested-action-fork-branches

Conversation

Copilot AI commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Tested similar dummy workflow here

-> yash-learner/test_actions#7, -> Fork
-> yash-learner/test_actions#8 -> Base

As we can't test these workflows before merging into main

Proposed Changes

pull_request_review events don't receive repository secrets for fork PRs, so actions/create-github-app-token fails with appId option is required since secrets.APP_ID is empty.

Fix: use the workflow_run pattern to decouple the review event (no secrets needed) from the label management (secrets needed).

  • New .github/workflows/pr-review-trigger.yml: Lightweight workflow on pull_request_review: submitted that saves PR number + review state as artifacts. Needs no secrets, runs with permissions: {}.
  • Modified .github/workflows/pr-automation.yml:
    • Replaced pull_request_review trigger with workflow_run: ["PR Review Trigger"] (always runs in base repo context → has secrets)
    • Scoped assign-pr job to pull_request_target events only
    • Added handle-review job: pre-checks artifact existence via gh api (no continue-on-error), validates inputs (numeric PR number, known review state allowlist), generates app token, manages labels
    • Explicit artifact existence check replaces continue-on-error: true — missing artifact (non-changes_requested reviews) logs a clear message and skips gracefully; real failures (permissions, network) now fail loudly
    • Added actions: read permission for cross-workflow artifact download

Tagging: @ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate the bug or test the new feature.
  • Update product documentation.
  • Ensure that UI text is placed in I18n files.
  • Prepare a screenshot or demo video for the changelog entry and attach it to the issue.
  • Request peer reviews.
  • Complete QA on mobile devices.
  • Complete QA on desktop devices.
  • Add or update Playwright tests for related changes
Original prompt

This section details on the original issue you should resolve

<issue_title>Fix changes requested action for fork branches</issue_title>
<issue_description>PR automation https://github.com/ohcnetwork/care_fe/blob/develop/.github/workflows/pr-automation.yml -> changes requested action fails on PR's from fork branches

I think review_requested event does not run on fork branches

https://github.com/ohcnetwork/care_fe/actions/runs/23244287387/job/67568454570?pr=16120

Run actions/create-github-app-token@v2
Inputs 'owner' and 'repositories' are not set. Creating token for this repository (ohcnetwork/care_fe).
Error: [@octokit/auth-app] appId option is required
    at createAppAuth (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:47665:11)
    at main (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:47956:17)
    at Object.<anonymous> (/home/runner/work/_actions/actions/create-github-app-token/v2/dist/main.cjs:48079:20)
    at Module._compile (node:internal/modules/cjs/loader:1521:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1623:10)
    at Module.load (node:internal/modules/cjs/loader:1266:32)
    at Module._load (node:internal/modules/cjs/loader:1091:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
    at node:internal/main/run_main_module:28:49
Error: [@octokit/auth-app] appId option is required
```</issue_description>

<agent_instructions>PR automation https://github.com/ohcnetwork/care_fe/blob/develop/.github/workflows/pr-automation.yml -> changes requested action fails on PR's from fork branches 

I think `review_requested` event does not run on fork branches 

You need to research and understand github pull_request_target types and come up with best work around for this 

Also do your research why it might be failing on PR's from fork branches before working on the solution

</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
</comments>


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

The pull_request_review event doesn't provide repository secrets for
fork PRs, causing the GitHub App token generation to fail. This change
splits the review handling into a two-workflow pattern:

1. pr-review-trigger.yml: Lightweight trigger on pull_request_review
   that saves review info as artifacts (no secrets needed)
2. pr-automation.yml: Handles the workflow_run event from the trigger,
   downloads artifacts, and manages labels with full secret access

Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 18, 2026

Copy link
Copy Markdown

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: d8d26e3
Status: ✅  Deploy successful!
Preview URL: https://e6a57f1b.care-preview-a7w.pages.dev
Branch Preview URL: https://copilot-fix-changes-requeste.care-preview-a7w.pages.dev

View logs

Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix changes requested action for fork branches Fix changes requested action for fork branches Mar 18, 2026
Copilot AI requested a review from yash-learner March 18, 2026 15:03
@yash-learner yash-learner moved this to In Progress in Care Develop Mar 22, 2026
@github-actions github-actions Bot added the stale label Mar 26, 2026
@Jacobjeevan

Copy link
Copy Markdown
Contributor

@yash-learner Status?

@Jacobjeevan Jacobjeevan removed the stale label Apr 2, 2026
@yash-learner

Copy link
Copy Markdown
Member

@yash-learner Status?

Need to review and test, myself

Will try to get it ready for review by Monday

@Jacobjeevan

@github-actions

github-actions Bot commented Apr 2, 2026

Copy link
Copy Markdown

🎭 Playwright Test Results

Status: ⏭️ Skipped

No test-related files were changed in this PR.

Tests are skipped when changes don't affect:

  • tests/**
  • src/**
  • package.json
  • playwright.config.ts

Run: #8280

@yash-learner yash-learner marked this pull request as ready for review April 5, 2026 18:44
@yash-learner yash-learner requested review from a team and Copilot April 5, 2026 18:44

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

jobs:
assign-pr:
runs-on: ubuntu-24.04-arm
# Skip workflow for PRs created by bots

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably we should run this workflow for bots as well because we are opening PR's with copilot as author

Let;s handle this in a separate PR, later

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes PR label automation for forked PRs by moving “changes requested” handling out of the pull_request_review workflow context (which lacks repo secrets on forks) and into a base-repo workflow_run follow-up that can safely access secrets.

Changes:

  • Added a lightweight pull_request_review workflow that records review metadata to an artifact only when the review state is changes_requested.
  • Updated the main PR automation workflow to trigger review-label handling via workflow_run of the new trigger workflow (with an explicit artifact existence check).
  • Scoped existing PR assignment automation to only run on pull_request_target events, and added actions: read permission to support cross-workflow artifact download.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
.github/workflows/pr-review-trigger.yml Adds a minimal review-submitted trigger that uploads PR number + review state as an artifact for changes_requested.
.github/workflows/pr-automation.yml Switches review handling to workflow_run, downloads/validates artifact data, and applies the “changes required” label using an app token.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

- name: Upload review info
uses: actions/upload-artifact@v4
with:
name: review-info

Copilot AI Apr 5, 2026

Copy link

Choose a reason for hiding this comment

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

Consider setting a short retention-days for the review-info artifact (similar to other ephemeral artifacts in this repo) to avoid accumulating artifacts for every changes_requested review over time.

Suggested change
name: review-info
name: review-info
retention-days: 1

Copilot uses AI. Check for mistakes.
@Jacobjeevan Jacobjeevan requested a review from jesbinjoseph April 6, 2026 10:05
Copilot AI review requested due to automatic review settings April 10, 2026 13:31
@netlify

netlify Bot commented Apr 10, 2026

Copy link
Copy Markdown

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit d8d26e3
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/69dcbeeadc80b1000815f708
😎 Deploy Preview https://deploy-preview-16148.preview.ohc.network
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@jesbinjoseph jesbinjoseph left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good to me.

exit 1
fi

if [[ "$REVIEW_STATE" != "changes_requested" && "$REVIEW_STATE" != "approved" && "$REVIEW_STATE" != "commented" && "$REVIEW_STATE" != "dismissed" ]]; then

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I can't find much on possible values of github.event.review.state 🤔 (they really should have better documentation for this!) but seems fine.

@Jacobjeevan Jacobjeevan added reviewed reviewed by a core member needs peer review labels Apr 24, 2026
@Jacobjeevan Jacobjeevan requested a review from sainak April 24, 2026 07:15
@parvathyns-creator

Copy link
Copy Markdown

@nihal467 this looks fine

@amjithtitus09 amjithtitus09 merged commit a8809cd into develop May 20, 2026
25 checks passed
@amjithtitus09 amjithtitus09 deleted the copilot/fix-changes-requested-action-fork-branches branch May 20, 2026 11:43
pranavrutagi-egov pushed a commit to care-ecosystem/care_fe that referenced this pull request May 22, 2026
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>
jagankumar-egov added a commit to care-ecosystem/care_fe that referenced this pull request May 24, 2026
* [ENG-314] Show all medication administration reports in drug chart  (ohcnetwork#16355)

* Fix: Reset role search query on dropdown close (ohcnetwork#16124)

* Fix logo handling in Print Preview (ohcnetwork#16217)

* Complete Encounter Without Dependency on Appointment and Token (ohcnetwork#15688)

* Remove facilityOrg.setup.ts - now handled by backend fixtures (ohcnetwork#16360)

* ENG-338 feat: add store internal type and inventory view functionality (ohcnetwork#16364)

* Make Payment sheet url accessible in Account & Invoice (ohcnetwork#16337)

* Fix: Responsibilities Page: Fixed Mobile Clear Button (ohcnetwork#16276)

* Fix changes requested action for fork branches (ohcnetwork#16148)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>

* Plugin Integration: Feedback + Complaint Management

---------

Co-authored-by: Muhammed Sawad <sawadmuhammedpm@gmail.com>
Co-authored-by: Bodhish Thomas <bodhish@gmail.com>
Co-authored-by: Deep <244596472+Deepcode007@users.noreply.github.com>
Co-authored-by: Yaswanth Kumar Bethu <yash.topaz@gmail.com>
Co-authored-by: Nikhila C <115739037+NikhilA8606@users.noreply.github.com>
Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Abhimanyu Rajeesh <63541653+abhimanyurajeesh@users.noreply.github.com>
Co-authored-by: Amjith Titus <amjithtitus09@gmail.com>
Co-authored-by: Pranav Rustagi <pranav.rutagi@egovernments.org>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>
jagankumar-egov pushed a commit to care-ecosystem/care_fe that referenced this pull request May 24, 2026
* [ENG-314] Show all medication administration reports in drug chart  (ohcnetwork#16355)

* Fix: Reset role search query on dropdown close (ohcnetwork#16124)

* Fix logo handling in Print Preview (ohcnetwork#16217)

* Complete Encounter Without Dependency on Appointment and Token (ohcnetwork#15688)

* Remove facilityOrg.setup.ts - now handled by backend fixtures (ohcnetwork#16360)

* ENG-338 feat: add store internal type and inventory view functionality (ohcnetwork#16364)

* Make Payment sheet url accessible in Account & Invoice (ohcnetwork#16337)

* Fix: Responsibilities Page: Fixed Mobile Clear Button (ohcnetwork#16276)

* Fix changes requested action for fork branches (ohcnetwork#16148)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>

* Plugin Integration: Feedback + Complaint Management

---------

Co-authored-by: Muhammed Sawad <sawadmuhammedpm@gmail.com>
Co-authored-by: Bodhish Thomas <bodhish@gmail.com>
Co-authored-by: Deep <244596472+Deepcode007@users.noreply.github.com>
Co-authored-by: Yaswanth Kumar Bethu <yash.topaz@gmail.com>
Co-authored-by: Nikhila C <115739037+NikhilA8606@users.noreply.github.com>
Co-authored-by: Mohammed Nihal <57055998+nihal467@users.noreply.github.com>
Co-authored-by: Abhimanyu Rajeesh <63541653+abhimanyurajeesh@users.noreply.github.com>
Co-authored-by: Amjith Titus <amjithtitus09@gmail.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: yash-learner <53794102+yash-learner@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs peer review reviewed reviewed by a core member

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Fix changes requested action for fork branches

7 participants