Skip to content

update-issue: attach or update issue artifacts on an existing issue #75973

Done

Description

@johnwilliams-12

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: only create_issue has an artifacts property; update_issue has none.
  • actions/setup/js/issue_artifacts.cjs: createIssueArtifacts(githubClient, owner, repo, issueNumber, artifacts, maxSizeBytes) already takes any issue number, but only create_issue.cjs calls it, after creating the issue.
  • The privileged createIssue helper for custom safe-output jobs does not cover this either. Per docs/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 POST and PATCH /repos/{owner}/{repo}/issues/{issue_number}/artifacts[/{artifact_number}] with issues: write, which the safe_outputs job already holds for update-issue. The same job token already posts artifacts for create_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)

  1. pkg/parser/schemas/main_workflow_schema.json and the update-issue config in pkg/workflow: accept max-issue-artifacts and max-issue-artifact-size with the same defaults and parsing as create-issue.
  2. actions/setup/js/safe_outputs_tools.json and pkg/workflow/js/safe_outputs_tools.json: add the artifacts input of create_issue (inline body or path) to update_issue.
  3. actions/setup/js/issue_artifacts.cjs: add upsertIssueArtifacts(...), which lists the issue's artifacts and calls PATCH for an existing name or POST for a new one, after sanitizeIssueArtifacts.
  4. actions/setup/js/update_issue.cjs: validate with normalizeIssueArtifacts and call upsertIssueArtifacts on the target issue. Report attachment failures the same way create_issue.cjs does.
  5. Tests next to each file: create, update by name, the limit exceeded, and artifacts disabled.
  6. Docs: docs/src/content/docs/reference/safe-outputs.md and the safe-outputs specification.
  7. Run make agent-finish.

Acceptance criteria

  • With update-issue: { target: triggering }, an update_issue call with artifacts: [{ 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-issue the right home, or would maintainers prefer a separate add-issue-artifact output?
  • Should add-comment targets also accept artifacts?

Not checked

  • The PATCH path, end to end, from a safe_outputs job. create_issue only uses POST. The REST docs give the same permission requirement for both.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions