ci(auto-add-to-project): make reusable via workflow_call, pin action version#4
Conversation
…version, lock down permissions
…version, lock down permissions
yujiawei
left a comment
There was a problem hiding this comment.
Code Review — PR #4 (.github)
Verdict: Approve
Small, well-scoped change that converts the existing auto-add-to-project.yml into a dual-mode workflow (direct trigger + workflow_call). The diff is +12/-1 in a single file and does what the description claims.
What's good
- Dual-mode design is correct. Adding
workflow_callalongside the existingissues/pull_request_targettriggers preserves coverage of the.githubrepo itself and unlocks per-repo callers — no behavior regression for the existing path. - Action pinned to a commit SHA.
actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133ematches the upstreamv1.0.2tag (verified againstactions/add-to-projectgit refs). The trailing# v1.0.2comment is the format Dependabot recognizes for SHA-pinned actions, so updates will continue to flow. permissions: {}at the top level is the right default. The job authenticates to the Projects v2 GraphQL API using thePROJECT_TOKENPAT passed as the action'sgithub-tokeninput; the ambientGITHUB_TOKENdoesn't need any scopes, so locking it down is least-privilege done right. The inline comment makes the intent explicit.workflow_call.secrets.PROJECT_TOKENis declaredrequired: true, which gives callers a clean failure mode if they forget to forward the secret.- PR description is aware of the merge ordering constraint (callers reference
@main, so this must land first). Good operational hygiene.
Notes / non-blocking suggestions
-
Caller pinning (out of scope for this PR, but worth flagging for the caller PRs). The description mentions callers will reference this workflow as
@main. For an org-internal reusable workflow that's defensible, but consider pinning callers to a tag or SHA ofMininglamp-OSS/.githubonce this stabilizes —@mainmeans a future change here ships instantly to every caller with no review surface on the caller side. -
pull_request_targetsecurity posture is fine here, but worth re-asserting. This workflow doesn't check out PR head code, doesn't execute untrusted scripts, and doesn't expose the PAT to forked-PR contexts beyond the action's own GraphQL call. If anyone later adds steps to this job, they should rememberpull_request_targetruns with the base-ref context and access to secrets — keep this job narrowly scoped to "add to project." -
No
concurrencygroup. Not needed —actions/add-to-projectis idempotent on already-added items, so duplicate triggers won't cause issues. Mentioning only so the absence is intentional. -
Top-of-file comment is helpful. Consider also adding a one-line "callers: see
<pattern>in repo<X>" pointer once at least one caller PR has merged, so future maintainers can find the consumer side without grepping the org. Not required now.
Verification
- Confirmed action SHA
244f685bbc3b7adfa8466e08b698b5577571133eresolves to tagv1.0.2upstream. - Confirmed YAML structure parses (single-doc, top-level
on/permissions/jobsshape is valid for both direct and reusable workflows). - Confirmed the existing direct-trigger behavior is preserved (the
issues.openedandpull_request_target.openedtriggers are unchanged; only additive changes).
Nothing here blocks merge. Approve.
What
Converts
auto-add-to-project.ymlfrom a standalone workflow (that only fired for events in the.githubrepo itself) into a dual-mode workflow:issues.opened+pull_request_target.opened— still covers the.githubrepoworkflow_callacceptingPROJECT_TOKENsecret — called by per-repo callers in all other org reposWhy
The original workflow only auto-added items from the
.githubrepo to Project Board #2. All other repos (octo-web, octo-server, etc.) were silently uncovered. This is the org-layer fix; per-repo callers are deployed in separate PRs.Changes
workflow_calltrigger withPROJECT_TOKENsecret declarationpermissions: {}(GITHUB_TOKEN needs no permissions here)actions/add-to-projectfrom@v1to@244f685b(v1.0.2)Merge order
This PR should merge before the per-repo caller PRs. Callers reference
@main, so the reusable must exist onmainfirst.