Repository navigation
Description
Summary
Since #75323, create-issue can attach issue artifacts to the issues it creates. No safe output can attach or update an artifact on an existing issue, so a workflow that works on the triggering issue cannot publish its result as an artifact there. This request asks for artifacts on update-issue, upserted by name, so that a second run adds a new version instead of a second artifact.
Use case
A planning workflow starts when a maintainer labels an existing issue. It writes a plan and creates sub-issues. The plan belongs on the labelled issue as an artifact of type plan, because artifacts keep their version history and a maintainer approves one version. Today the agent can only post the plan as a comment, or a custom job has to call the REST API itself. The custom job bypasses the sanitizing and size limits that #75323 added.
Current behaviour (main and v1.2.1)
actions/setup/js/safe_outputs_tools.json: onlycreate_issuehas anartifactsproperty;update_issuehas none.actions/setup/js/issue_artifacts.cjs:createIssueArtifacts(githubClient, owner, repo, issueNumber, artifacts, maxSizeBytes)already takes any issue number, but onlycreate_issue.cjscalls it, after creating the issue.- The privileged
createIssuehelper for custom safe-output jobs does not cover this either. Perdocs/src/content/docs/reference/custom-safe-outputs.md, it validates artifacts "before issue creation and attached afterward", so it too attaches only to the issue it creates. - The REST API allows
POSTandPATCH /repos/{owner}/{repo}/issues/{issue_number}/artifacts[/{artifact_number}]with issues: write, which thesafe_outputsjob already holds forupdate-issue. The same job token already posts artifacts forcreate_issue; Support issue artifacts in create-issue safe outputs #75323 verified this live in [Live test] create-issue artifact support #75354.
Proposed change (plan for an agent)
pkg/parser/schemas/main_workflow_schema.jsonand theupdate-issueconfig inpkg/workflow: acceptmax-issue-artifactsandmax-issue-artifact-sizewith the same defaults and parsing ascreate-issue.actions/setup/js/safe_outputs_tools.jsonandpkg/workflow/js/safe_outputs_tools.json: add theartifactsinput ofcreate_issue(inlinebodyorpath) toupdate_issue.actions/setup/js/issue_artifacts.cjs: addupsertIssueArtifacts(...), which lists the issue's artifacts and callsPATCHfor an existing name orPOSTfor a new one, aftersanitizeIssueArtifacts.actions/setup/js/update_issue.cjs: validate withnormalizeIssueArtifactsand callupsertIssueArtifactson the target issue. Report attachment failures the same waycreate_issue.cjsdoes.- Tests next to each file: create, update by name, the limit exceeded, and artifacts disabled.
- Docs:
docs/src/content/docs/reference/safe-outputs.mdand the safe-outputs specification. - Run
make agent-finish.
Acceptance criteria
- With
update-issue: { target: triggering }, anupdate_issuecall withartifacts: [{ name: "Plan", type: "plan", body: "..." }]creates the artifact on the triggering issue. - A second run with the same name adds a new version of that artifact; it does not create a second artifact.
Open questions
- Is
update-issuethe right home, or would maintainers prefer a separateadd-issue-artifactoutput? - Should
add-commenttargets also accept artifacts?
Not checked
- The
PATCHpath, end to end, from asafe_outputsjob.create_issueonly usesPOST. The REST docs give the same permission requirement for both.
Activity