Skip to content

chore: Refactor Sync Linked Issue Labels Worflow#2095

Merged
exploreriii merged 5 commits into
hiero-ledger:mainfrom
manishdait:fix/sync_issue_wf
Apr 11, 2026
Merged

chore: Refactor Sync Linked Issue Labels Worflow#2095
exploreriii merged 5 commits into
hiero-ledger:mainfrom
manishdait:fix/sync_issue_wf

Conversation

@manishdait

@manishdait manishdait commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Description:
This PR refactor sync issue labels two-stage workflow to securely synchronize labels from linked issues to Pull Requests. also skip the automated bots PR.

Changes Made:

  • Remove dependency on PAT token.
  • Skip the apply action on Bot PR.

Related issue(s):

Fixes #2094

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

@codacy-production

codacy-production Bot commented Apr 9, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

TIP This summary will be updated as you push new changes. Give us feedback

@codecov

codecov Bot commented Apr 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2095   +/-   ##
=======================================
  Coverage   93.70%   93.70%           
=======================================
  Files         145      145           
  Lines        9452     9452           
=======================================
  Hits         8857     8857           
  Misses        595      595           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@manishdait
manishdait marked this pull request as ready for review April 9, 2026 19:47
@manishdait
manishdait requested review from a team as code owners April 9, 2026 19:47
@coderabbitai

coderabbitai Bot commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

The changes refactor two GitHub Actions workflows that manage linked issue labels on pull requests. The compute workflow now triggers automatically on PR events (instead of manual dispatch), reads the PR number from the GitHub context payload, and uses simplified linked-issue and label extraction logic. The add workflow converts to an automatic trigger that runs after compute succeeds, downloading artifacts and applying labels directly via the GitHub API without manual dispatch intervention.

Changes

Cohort / File(s) Summary
Workflow Automation Refactoring
.github/workflows/sync-issue-labels-compute.yml, .github/workflows/sync-issue-labels-add.yml
Restructured workflows from manual workflow_dispatch triggers to automatic event-driven execution. Compute workflow now triggers on PR events and simplified linked-issue detection (single regex pattern, no truncation), label extraction (issues only, deduplicated via Set), and artifact payload (removed is_fork_pr, dry_run, source_event fields; renamed artifact to pr-labels-data). Add workflow now auto-triggers after compute succeeds, replacing actions-ecosystem/action-add-labels with actions/github-script for direct GitHub API label application. Both workflows skip bot-authored PRs.
Documentation
CHANGELOG.md
Added changelog entry documenting the refactoring of sync-issue-labels workflows to properly handle label syncing and skip bot PRs.

Sequence Diagram

sequenceDiagram
    participant PR as Pull Request Event
    participant Compute as Compute Job
    participant Artifact as Artifact Storage
    participant Add as Add Job
    participant API as GitHub API

    PR->>Compute: PR opened/edited/reopened/synchronized
    Compute->>Compute: Read PR number from context.payload
    Compute->>Compute: Extract linked issues (regex: fix/close/resolve `#N`)
    Compute->>Compute: Gather labels from linked issues
    Compute->>Compute: Calculate new labels (not already on PR)
    Compute->>Artifact: Upload pr-labels-data artifact<br/>(pr_number, labels)
    
    Compute-->>Add: Workflow completion signal (success)
    Add->>Artifact: Download pr-labels-data artifact
    Add->>Add: Read labels.json from workspace
    Add->>API: Call github.rest.issues.addLabels<br/>(pr_number, labels)
    API-->>Add: Labels applied
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Refactor Sync Linked Issue Labels Worflow' is directly related to the main changes; however, it contains a typo ('Worflow' should be 'Workflow').
Description check ✅ Passed The description clearly relates to the changeset, explaining the refactoring of the two-stage workflow, removal of PAT token dependency, and skipping bot PRs, which matches the code changes.
Linked Issues check ✅ Passed The PR addresses the linked issue #2094 by implementing bot PR detection and skipping; the compute workflow now returns early for bot-authored PRs without setting outputs.
Out of Scope Changes check ✅ Passed All changes are in scope: the workflow refactoring, removal of PAT dependency, bot PR skipping logic, and CHANGELOG update directly support the objective in issue #2094.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d037c487-d836-4260-ae2d-41b0a269f402

📥 Commits

Reviewing files that changed from the base of the PR and between 7571b15 and 06f5101.

📒 Files selected for processing (3)
  • .github/workflows/sync-issue-labels-add.yml
  • .github/workflows/sync-issue-labels-compute.yml
  • CHANGELOG.md

Comment thread .github/workflows/sync-issue-labels-add.yml
Comment thread .github/workflows/sync-issue-labels-compute.yml
Comment thread CHANGELOG.md Outdated

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1aab695e-902d-4fbc-8bb7-25be2285662a

📥 Commits

Reviewing files that changed from the base of the PR and between 06f5101 and 0a9b649.

📒 Files selected for processing (3)
  • .github/workflows/sync-issue-labels-add.yml
  • .github/workflows/sync-issue-labels-compute.yml
  • CHANGELOG.md

Comment thread .github/workflows/sync-issue-labels-compute.yml
@exploreriii

Copy link
Copy Markdown
Contributor

rebase please @manishdait

exploreriii
exploreriii previously approved these changes Apr 11, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1c949005-e2ee-4db9-9954-fb78cff99ad8

📥 Commits

Reviewing files that changed from the base of the PR and between 0a9b649 and 74dc2cc.

📒 Files selected for processing (3)
  • .github/workflows/sync-issue-labels-add.yml
  • .github/workflows/sync-issue-labels-compute.yml
  • CHANGELOG.md

Comment thread .github/workflows/sync-issue-labels-add.yml
Comment thread .github/workflows/sync-issue-labels-add.yml
Comment thread .github/workflows/sync-issue-labels-add.yml
Comment thread .github/workflows/sync-issue-labels-add.yml
Comment thread .github/workflows/sync-issue-labels-compute.yml
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
Signed-off-by: Manish Dait <daitmanish88@gmail.com>

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

♻️ Duplicate comments (2)
.github/workflows/sync-issue-labels-add.yml (1)

27-32: ⚠️ Potential issue | 🟠 Major

Guard the artifact download for expected no-op runs.

sync-issue-labels-compute.yml returns early for bot-authored PRs, for PRs with no linked issues, and when there are no new labels, and it only uploads pr-labels-data when labels.json exists. This step still downloads the artifact unconditionally, so those normal skip paths fail here before Line 39 can short-circuit on a missing file.

🔧 One way to gate the download
+      - name: Check Artifact Exists
+        id: artifact
+        uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
+        with:
+          script: |
+            const { data } = await github.rest.actions.listWorkflowRunArtifacts({
+              owner: context.repo.owner,
+              repo: context.repo.repo,
+              run_id: context.payload.workflow_run.id,
+            });
+            core.setOutput(
+              'exists',
+              data.artifacts.some((artifact) => artifact.name === 'pr-labels-data') ? 'true' : 'false',
+            );
+
       - name: Download Artifact
+        if: steps.artifact.outputs.exists == 'true'
         uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
         with:
           name: pr-labels-data
.github/workflows/sync-issue-labels-compute.yml (1)

7-9: ⚠️ Potential issue | 🔴 Critical

Declare pull-requests: read for the retained pulls.get() call.

The script still calls github.rest.pulls.get(...) on Lines 32-34, but this workflow only grants issues: read and contents: read. Once permissions: is declared, the token is scoped to those entries, and GitHub documents GET /repos/{owner}/{repo}/pulls/{pull_number} as a pull-request read endpoint. On repositories using restricted workflow permissions, this can turn the compute step into a 403. (docs.github.com)

🔧 Minimal fix
 permissions:
   issues: read
+  pull-requests: read
   contents: read

As per coding guidelines, permissions: must be explicitly declared and scoped to the minimum needed.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: d11a74a0-9589-4cdc-91eb-270ad7f76324

📥 Commits

Reviewing files that changed from the base of the PR and between 7c5c0c8 and beed2b6.

📒 Files selected for processing (3)
  • .github/workflows/sync-issue-labels-add.yml
  • .github/workflows/sync-issue-labels-compute.yml
  • CHANGELOG.md

Comment thread .github/workflows/sync-issue-labels-add.yml
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@exploreriii exploreriii removed the reviewer: maintainer PR needs a review from the maintainer team label Apr 11, 2026
@exploreriii exploreriii added the step: 2nd second stage of the review approval process label Apr 11, 2026
@exploreriii
exploreriii merged commit 9360ad4 into hiero-ledger:main Apr 11, 2026
15 checks passed
@exploreriii

Copy link
Copy Markdown
Contributor

Thanks @manishdait and @AntonioCeppellini !

MonaaEid pushed a commit to MonaaEid/hiero-sdk-python that referenced this pull request Apr 16, 2026
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
AntonioCeppellini pushed a commit to AntonioCeppellini/hiero-sdk-python that referenced this pull request Apr 22, 2026
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
parvninama pushed a commit to parvninama/hiero-sdk-python that referenced this pull request Apr 25, 2026
Signed-off-by: Manish Dait <daitmanish88@gmail.com>
@manishdait
manishdait deleted the fix/sync_issue_wf branch June 5, 2026 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

step: 2nd second stage of the review approval process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the Sync Linked Issue Labels to skip on bot PR

3 participants