Skip to content

Comments

[pipeline] Use GHA workflow triggers to run labeler workflow#4274

Open
yuxiqian wants to merge 1 commit intoapache:masterfrom
yuxiqian:fix/labeler
Open

[pipeline] Use GHA workflow triggers to run labeler workflow#4274
yuxiqian wants to merge 1 commit intoapache:masterfrom
yuxiqian:fix/labeler

Conversation

@yuxiqian
Copy link
Member

A workaround for workflow failure introduced in #4263.

Copy link
Contributor

Copilot AI left a comment

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 implements a security improvement for the labeler workflow by splitting it into a trigger workflow and a main workflow, following the workflow_run pattern. This addresses security concerns introduced in PR #4263 by ensuring that workflows with write permissions (like applying labels to PRs) run in the context of the default branch rather than in the PR branch context, preventing potential malicious code in PRs from accessing write tokens.

Changes:

  • Created new label_trigger.yml workflow that triggers on pull_request events targeting master and release-* branches
  • Modified label.yml to use workflow_run trigger instead of direct pull_request trigger, and added explicit permissions declarations

Reviewed changes

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

File Description
.github/workflows/label_trigger.yml New trigger workflow that runs on pull_request events with minimal permissions, triggering the main labeler workflow via workflow_run
.github/workflows/label.yml Changed from direct pull_request trigger to workflow_run trigger, added workflow-level and job-level permissions declarations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# This workflow will triage pull requests and apply a label based on the
# paths that are modified in the pull request.
#
# To use this workflow, you will need to set up a .github/label.yml
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

The comment references ".github/label.yml" but the actual configuration file appears to be ".github/labeler.yml" (as evidenced by the file existing in the repository). This documentation discrepancy could cause confusion for maintainers.

Suggested change
# To use this workflow, you will need to set up a .github/label.yml
# To use this workflow, you will need to set up a .github/labeler.yml

Copilot uses AI. Check for mistakes.
Comment on lines 38 to 41
permissions:
checks: write
contents: read
pull-requests: write
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

Permissions are specified at both the workflow level (lines 30-33) and job level (lines 38-41). This duplication is redundant when the permissions are identical. Consider removing the job-level permissions declaration to match the pattern used in approve_label.yml, which only specifies permissions at the workflow level.

Suggested change
permissions:
checks: write
contents: read
pull-requests: write

Copilot uses AI. Check for mistakes.
- release-*
workflow_run:
workflows: [Labeler-Trigger]
types: [requested]
Copy link

Copilot AI Feb 24, 2026

Choose a reason for hiding this comment

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

When using workflow_run triggers, the labeler action needs access to the pull request context to apply labels. While actions/labeler@v6 has support for workflow_run events, it relies on github.event.workflow_run.pull_requests being populated.

This should work since the triggering workflow (Labeler-Trigger) is triggered by pull_request events. However, unlike approve_label.yml which explicitly retrieves PR context using get-workflow-origin (lines 42-47), this implementation relies on the labeler action's built-in workflow_run support.

Consider testing this thoroughly, or add explicit PR context retrieval similar to approve_label.yml to ensure the labeler can identify which PR to label in all cases.

Suggested change
types: [requested]
types: [completed]

Copilot uses AI. Check for mistakes.
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.

1 participant