RDKB-66032 : Add auto cherry-pick and gatekeeper workflow callers - #65
RDKB-66032 : Add auto cherry-pick and gatekeeper workflow callers#65bunnam988 wants to merge 7 commits into
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Pull request overview
Adds two GitHub Actions “workflow caller” entries to this repo to integrate with the shared automation in rdkcentral/build_tools_workflows: one for auto cherry-picking/backport PR creation and one for “topic gatekeeper” review enforcement.
Changes:
- Add
auto-backport.ymlto invoke the shared cherry-pick/backport engine after merge when acherry-pick to <branch>label is present. - Add
gatekeeper.ymlto invoke the shared gatekeeper workflow on PR activity and review submission for develop/release/support branch targets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| .github/workflows/gatekeeper.yml | Adds a reusable-workflow caller for the shared gatekeeper on PR and review events. |
| .github/workflows/auto-backport.yml | Adds a reusable-workflow caller for the shared cherry-pick/backport engine on PR events. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
668920c to
2c36e72
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (3)
.github/workflows/gatekeeper.yml:4
- This workflow caller doesn’t declare explicit
permissions. Because reusable workflows inherit the caller’sGITHUB_TOKENpermissions, gatekeeper may be unable to set commit statuses/checks or post PR comments depending on the repo/org default. Add an explicit permissions block appropriate for the shared gatekeeper workflow.
name: Topic Gatekeeper
on:
pull_request:
.github/workflows/auto-backport.yml:13
pull_requestevent includes bothlabeledandclosed, but the currentifwill also run on any label added after merge as long as the PR has acherry-pick to ...label somewhere. That can retrigger the cherry-pick engine and create duplicate backport PR attempts. Also,github.event.label.nameis undefined for theclosedaction, sotrigger_labelwill be empty/invalid on merge events.
cherry-pick:
if: github.event.pull_request.merged == true && contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')
uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop
with:
raw_labels: ${{ toJSON(github.event.pull_request.labels) }}
trigger_label: ${{ github.event.label.name }}
.github/workflows/auto-backport.yml:5
- This workflow caller doesn’t declare explicit
permissions. Reusable workflows inherit the caller’s token permissions, so behavior can vary (or fail) depending on the repo/org default permissions. Since the cherry-pick engine needs to create branches/PRs and post PR comments, explicitly grant the required write scopes here.
name: Automated Cherry-Pick Engine
on:
pull_request:
types: [labeled, closed]
- auto-backport.yml: triggers cherry-pick engine on PR merge with 'cherry-pick to <branch>' label - gatekeeper.yml: enforces cross-repo review sync before merge on develop, release, and support branches
2c36e72 to
26d78a7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (4)
.github/workflows/gatekeeper.yml:3
- This workflow calls a reusable workflow in rdkcentral/build_tools_workflows but does not declare explicit GITHUB_TOKEN permissions. In this repo, other reusable-workflow callers (e.g., .github/workflows/pr-lint.yml:7-10) set permissions explicitly; without them, the shared gatekeeper may fail to comment/update PRs depending on the repo's default token permissions. Define minimal required permissions here.
name: Topic Gatekeeper
on:
.github/workflows/auto-backport.yml:22
github.event.label.nameis only present for.../labeledevents; when this workflow runs onpull_requestclosed(merge) events,github.event.labelis undefined andtrigger_labelwill be empty/invalid. Settrigger_labelconditionally so merged/closed runs don't pass a missing value.
raw_labels: ${{ github.event_name == 'issues' && toJSON(github.event.issue.labels) || toJSON(github.event.pull_request.labels) }}
trigger_label: ${{ github.event.label.name }}
pr_number_override: ${{ github.event_name == 'issues' && github.event.issue.number || '' }}
.github/workflows/auto-backport.yml:3
- This workflow calls a reusable workflow in rdkcentral/build_tools_workflows but does not declare explicit GITHUB_TOKEN permissions. In this repo, other reusable-workflow callers (e.g., .github/workflows/pr-lint.yml:7-10) set permissions explicitly; without them, the shared cherry-pick engine may fail to create branches/PRs or post comments depending on the repo's default token permissions. Define minimal required permissions here.
name: Automated Cherry-Pick Engine
on:
.github/workflows/auto-backport.yml:17
github.event.issue.pull_request.url != ''does not reliably gate this job to PR-backed issues: for a regular issue thepull_requestfield is null, and the expression can still evaluate truthy, so labeling a normal issue with acherry-pick to ...label could incorrectly trigger the cherry-pick engine. Check for a non-nullpull_requestobject instead.
(github.event_name == 'issues' &&
github.event.issue.pull_request.url != '' &&
contains(toJSON(github.event.issue.labels.*.name), 'cherry-pick to '))
…herry-picks issues:labeled does not fire for pull requests in GitHub Actions (only for issues). workflow_dispatch lets users manually trigger cherry-pick from Actions tab for any already-merged PR by entering the PR number and target branch.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (5)
.github/workflows/auto-backport.yml:28
trigger_labelfalls back togithub.event.label.name, but for thepull_requestclosedaction there is nogithub.event.labelpayload. That can result in a null/empty value being passed to the reusable workflow (or an expression evaluation error depending on how the called workflow consumes it). Handle the non-labeledpull_request actions explicitly and pass an empty string (the called workflow can still infer fromraw_labels).
raw_labels: ${{ github.event_name == 'workflow_dispatch' && format('[{{"name":"cherry-pick to {0}"}}]', inputs.target_branch) || toJSON(github.event.pull_request.labels) }}
trigger_label: ${{ github.event_name == 'workflow_dispatch' && format('cherry-pick to {0}', inputs.target_branch) || github.event.label.name }}
pr_number_override: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || '' }}
.github/workflows/auto-backport.yml:24
- This workflow calls a reusable workflow pinned to the moving
developbranch. For supply-chain safety and reproducibility, prefer pinning reusable workflows to a tag or commit SHA so behavior can’t change unexpectedly without updating this repo.
uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop
.github/workflows/gatekeeper.yml:13
- This workflow doesn’t declare
permissions:forGITHUB_TOKEN. Other workflows in this repo explicitly set least-privilege permissions (e.g..github/workflows/pr-lint.yml:7-10,.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml:7-10). Without an explicit block, token permissions depend on the repository/org default and can break posting status/comments or other GitHub API calls from the reusable workflow. Add an explicitpermissions:` block aligned with what the reusable workflow needs.
pull_request_review:
types: [submitted]
jobs:
.github/workflows/auto-backport.yml:24
- This workflow doesn’t declare
permissions:forGITHUB_TOKEN. Other workflows in this repo explicitly set least-privilege permissions (e.g..github/workflows/pr-lint.yml:7-10,.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml:7-10). Without an explicit block, this job’s token permissions depend on the repository/org default and may be too restrictive for creating backport branches/PRs or posting PR comments. Add an explicitpermissions:` block aligned with what the reusable workflow needs.
jobs:
cherry-pick:
if: |
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')) ||
github.event_name == 'workflow_dispatch'
uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop
.github/workflows/gatekeeper.yml:21
- This workflow calls a reusable workflow pinned to the moving
developbranch. For supply-chain safety and reproducibility, prefer pinning reusable workflows to a tag or commit SHA so behavior can’t change unexpectedly without updating this repo.
uses: rdkcentral/build_tools_workflows/.github/workflows/gatekeeper.yml@develop
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (4)
.github/workflows/auto-backport.yml:15
github.event.label.nameis only present for thepull_requestlabeledevent. When this workflow runs onpull_requestclosed(merge), that context will be null, which can break the shared reusable workflow input handling. Also, this workflow will run for fork PRs whereCROSS_REPO_TOKENis not available, causing avoidable failures/noise.
cherry-pick:
if: github.event.pull_request.merged == true && contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')
uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop
with:
raw_labels: ${{ toJSON(github.event.pull_request.labels) }}
trigger_label: ${{ github.event.label.name }}
secrets:
CROSS_REPO_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }}
.github/workflows/gatekeeper.yml:20
- This workflow will also trigger for fork PR activity (especially
pull_request_review), but secrets likeCROSS_REPO_TOKENare not provided to fork-basedpull_requestworkflows. Add a fork guard so the job is skipped for forks to avoid failing/noisy runs.
run-shared-gatekeeper:
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'pull_request_review' &&
(github.event.pull_request.base.ref == 'develop' ||
startsWith(github.event.pull_request.base.ref, 'release/') ||
startsWith(github.event.pull_request.base.ref, 'support/')))
.github/workflows/auto-backport.yml:7
- Other workflows in this repo declare explicit
permissions(e.g.,.github/workflows/pr-lint.ymland.github/workflows/cla.yml). Without an explicit permissions block here, the reusable cherry-pick workflow may run with insufficient defaultGITHUB_TOKENpermissions depending on repo/org settings (commonly read-only), preventing branch/PR creation or commenting.
This issue also appears on line 8 of the same file.
name: Automated Cherry-Pick Engine
on:
pull_request:
types: [labeled, closed]
jobs:
.github/workflows/gatekeeper.yml:13
- This workflow calls a reusable workflow and passes
CROSS_REPO_TOKEN, but (like the other workflows in this repo) it should declare explicitpermissionsso the called workflow has predictableGITHUB_TOKENcapabilities. Relying on repository/org defaults can cause the gatekeeper to be unable to comment or set checks/statuses.
This issue also appears on line 14 of the same file.
name: Topic Gatekeeper
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
- develop
- 'release/**'
- 'support/**'
pull_request_review:
types: [submitted]
jobs:
pull_request:labeled only fires for OPEN PRs, not merged ones. workflow_dispatch lets users manually trigger from Actions tab: enter PR number + target branch to cherry-pick any past merged PR.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
.github/workflows/auto-backport.yml:23
- For PRs originating from forks, repository secrets (including
CROSS_REPO_TOKEN) are not provided topull_request-triggered workflows. This job will likely run with an empty token and fail/no-op; consider skipping fork PRs (or switching topull_request_targetwith appropriate hardening).
if: |
(github.event_name == 'pull_request' &&
github.event.pull_request.merged == true &&
contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')) ||
github.event_name == 'workflow_dispatch'
.github/workflows/gatekeeper.yml:11
- If an approval is dismissed, this workflow will not re-run, so the gatekeeper check can remain in a stale "passing" state even though the PR is no longer approved. Include the
dismissedreview event type so the check status stays accurate.
types: [submitted]
.github/workflows/gatekeeper.yml:20
- This workflow unconditionally passes
CROSS_REPO_TOKENinto the reusable workflow. Onpull_request/pull_request_reviewevents from forks, secrets are not exposed, so the downstream workflow will likely fail and could block merges if the check is required. Consider skipping fork PRs (or switching topull_request_targetwith appropriate hardening).
github.event_name == 'pull_request' ||
(github.event_name == 'pull_request_review' &&
(github.event.pull_request.base.ref == 'develop' ||
startsWith(github.event.pull_request.base.ref, 'release/') ||
startsWith(github.event.pull_request.base.ref, 'support/')))
| uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop | ||
| with: | ||
| raw_labels: ${{ github.event_name == 'workflow_dispatch' && format('[{{"name":"cherry-pick to {0}"}}]', inputs.target_branch) || toJSON(github.event.pull_request.labels) }} | ||
| trigger_label: ${{ github.event_name == 'workflow_dispatch' && format('cherry-pick to {0}', inputs.target_branch) || github.event.label.name }} |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (5)
.github/workflows/auto-backport.yml:23
trigger_labelfalls back togithub.event.label.name, but the workflow also runs onpull_requestclosedevents (merge). Theclosedevent payload does not includegithub.event.label, so this input will be empty/undefined and can break the reusable cherry-pick workflow if it expects a non-empty trigger label. Gate this value ongithub.event.action == 'labeled', and otherwise pass an empty string (or derive fromraw_labels).
trigger_label: ${{ github.event_name == 'workflow_dispatch' && format('cherry-pick to {0}', inputs.target_branch) || github.event.label.name }}
.github/workflows/gatekeeper.yml:6
- This workflow calls a reusable workflow but doesn't declare explicit
permissions. In this repo, other reusable-workflow callers setpermissions(e.g..github/workflows/pr-lint.yml:7-10,.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml:7-10). Consider adding apermissions:block that matches the shared gatekeeper workflow’s needs so it doesn’t depend on repo/org defaults.
name: Topic Gatekeeper
on:
pull_request:
types: [opened, synchronize, reopened]
branches:
.github/workflows/auto-backport.yml:6
- This workflow calls a reusable workflow and passes
CROSS_REPO_TOKEN, but it doesn't declare explicitpermissions. If the repo/org defaultGITHUB_TOKENpermissions are set to read-only (common in orgs), the reusable workflow may fail when trying to create branches/PRs or post PR comments/statuses. Add an explicitpermissions:block that matches the shared cherry-pick workflow's documented requirements (at minimum likelycontents: writeandpull-requests: write).
name: Automated Cherry-Pick Engine
on:
pull_request:
types: [labeled, closed]
workflow_dispatch:
.github/workflows/auto-backport.yml:21
- The reusable workflow is referenced via
@develop, which is mutable. Since this workflow forwardsCROSS_REPO_TOKEN, pinning the reusable workflow to a tagged release or a commit SHA would reduce the risk of unexpected behavior changes (or compromised upstream) affecting this repo.
if: (github.event.pull_request.merged == true && contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')) || github.event_name == 'workflow_dispatch'
uses: rdkcentral/build_tools_workflows/.github/workflows/cherry-pick.yml@develop
with:
.github/workflows/gatekeeper.yml:21
- The reusable workflow is referenced via
@develop, which is mutable. For a policy-enforcement workflow like gatekeeper, pinning to a tagged release or commit SHA helps ensure deterministic behavior across time and reduces supply-chain risk.
uses: rdkcentral/build_tools_workflows/.github/workflows/gatekeeper.yml@develop
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (5)
.github/workflows/auto-backport.yml:13
trigger_labelis sourced fromgithub.event.label.name, but this workflow only actually runs when the PR is merged (theclosedaction). In that event payload,github.event.labelis not present, so this input will be null/empty and can break the called reusable workflow if it expects a value. Sinceraw_labelsalready contains all labels, consider droppingtrigger_label(or computing it frompull_request.labels).
with:
raw_labels: ${{ toJSON(github.event.pull_request.labels) }}
trigger_label: ${{ github.event.label.name }}
.github/workflows/gatekeeper.yml:20
- This workflow passes
CROSS_REPO_TOKEN, butpull_requestworkflows do not receive secrets for PRs opened from forks. If a forked PR targets develop/release/support, this job will fail at runtime due to the missing secret. Consider skipping fork PRs here (as done in.github/workflows/fossid_integration_stateless_diffscan_target_repo.yml:13) or switching to apull_request_target-based approach if it's safe for the called workflow.
if: |
github.event_name == 'pull_request' ||
(github.event_name == 'pull_request_review' &&
(github.event.pull_request.base.ref == 'develop' ||
startsWith(github.event.pull_request.base.ref, 'release/') ||
.github/workflows/auto-backport.yml:9
- This workflow passes
CROSS_REPO_TOKEN, butpull_requestworkflows do not receive secrets for PRs opened from forks. If a forked PR is merged with a cherry-pick label, this job will fail due to the missing secret. Consider skipping fork PRs here (or using apull_request_target-based approach if safe for the called workflow).
if: github.event.pull_request.merged == true && contains(toJSON(github.event.pull_request.labels.*.name), 'cherry-pick to ')
.github/workflows/auto-backport.yml:4
- This reusable-workflow caller does not declare
permissions. If the shared cherry-pick workflow usesGITHUB_TOKENto create branches/PRs or comment, it may fail when the repo default token permissions are read-only. Consider adding an explicit permissions block (likely needscontents: writeandpull-requests: write).
name: Automated Cherry-Pick Engine
on:
pull_request:
.github/workflows/gatekeeper.yml:4
- This reusable-workflow caller does not declare
permissions. Other callers in this repo (e.g..github/workflows/pr-lint.yml) set explicit permissions to ensure the called workflow can comment/update PRs even when the repo default GITHUB_TOKEN permissions are read-only. Consider adding an explicit permissions block here (at minimumpull-requests: writeif the shared gatekeeper posts PR comments).
name: Topic Gatekeeper
on:
pull_request:
Adds two workflow callers that integrate with the shared engine in rdkcentral/build_tools_workflows (PR #70).
auto-backport.yml— triggers on PR merge when labeledcherry-pick to <branch>:CROSS_REPO_TOKENsecret for cross-repo cascade (topic labels)gatekeeper.yml— triggers on PR open/sync/review:Reason for change: Enable automated backporting and cross-repo review enforcement
Test Procedure: Verified on bunnam988 fork — cherry-pick engine creates PRs, posts conflict/error comments; gatekeeper passes on develop
Risks: Low
Priority: P1