-
Notifications
You must be signed in to change notification settings - Fork 333
feat: add upload-artifact safe output type for run-scoped GitHub Actions artifact uploads #25002
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
465b20e
ff14be6
60b0376
1d4b6ad
a9e8f8f
ae61a26
f962e66
bedab80
fdeeba3
4efbf5b
d577e59
1684416
f0d8940
666601f
6b2777f
e9e9c61
36c1694
221a3fa
e1b9b28
b07adc9
568e236
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| --- | ||
| safe-outputs: | ||
| upload-artifact: | ||
| max-uploads: 3 | ||
| default-retention-days: 7 | ||
| max-retention-days: 30 | ||
| allow: | ||
| skip-archive: true | ||
| --- | ||
|
|
||
| <!-- | ||
| # Shared Upload Artifact Safe Output Configuration | ||
|
|
||
| This shared workflow enables the `upload_artifact` safe output tool, which lets AI agents | ||
| upload files as run-scoped GitHub Actions artifacts. | ||
|
|
||
| ## How it works | ||
|
|
||
| The agent stages files to `$RUNNER_TEMP/gh-aw/safeoutputs/upload-artifacts/` and calls the | ||
| `upload_artifact` tool. The `safe_outputs` job picks up the staged files and uploads them | ||
| directly via the `@actions/artifact` REST API (no `actions: write` permission needed — | ||
| authentication uses `ACTIONS_RUNTIME_TOKEN` which is always available to the runner). | ||
|
|
||
| The tool returns a temporary opaque artifact ID (`tmp_artifact_*`) that can be resolved to | ||
| a download URL by an authorised downstream step. | ||
|
|
||
| ## Usage | ||
|
|
||
| Import this shared workflow to enable `upload_artifact` in any workflow: | ||
|
|
||
| ```yaml | ||
| imports: | ||
| - shared/safe-output-upload-artifact.md | ||
| ``` | ||
|
|
||
| The agent must stage files before calling the tool: | ||
|
|
||
| ```bash | ||
| # Stage files to the upload-artifacts directory | ||
| cp dist/report.json $RUNNER_TEMP/gh-aw/safeoutputs/upload-artifacts/report.json | ||
| ``` | ||
|
|
||
| Then call the tool: | ||
|
|
||
| ```json | ||
| { "type": "upload_artifact", "path": "report.json", "retention_days": 7 } | ||
| ``` | ||
|
|
||
| ## Configuration defaults | ||
|
|
||
| - `max-uploads`: 3 uploads per run | ||
| - `default-retention-days`: 7 days | ||
| - `max-retention-days`: 30 days | ||
| - `allow.skip-archive`: true (single-file uploads can skip zip archiving) | ||
|
|
||
| Override any of these by defining `upload-artifact` directly in your workflow's | ||
| `safe-outputs` section (the top-level definition takes precedence over the import). | ||
| --> |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,10 @@ inputs: | |
| description: 'Install @actions/github for handlers that use a per-handler github-token (creates Octokit via getOctokit)' | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new |
||
| required: false | ||
| default: 'false' | ||
| safe-output-artifact-client: | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good addition —
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Smoke test agent dropping in! The
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. New
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Smoke test agent here! The |
||
| description: 'Install @actions/artifact so upload_artifact.cjs can upload GitHub Actions artifacts via REST API directly' | ||
| required: false | ||
| default: 'false' | ||
| job-name: | ||
| description: 'Name of the job being set up. When OTEL_EXPORTER_OTLP_ENDPOINT is configured, a gh-aw.<job-name>.setup span is pushed to the OTLP endpoint.' | ||
| required: false | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| { | ||
| "devDependencies": { | ||
| "@actions/artifact": "^6.0.0", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤖 Smoke test agent agrees! Pinning to a specific version like
|
||
| "@actions/core": "^3.0.0", | ||
| "@actions/exec": "^3.0.0", | ||
| "@actions/github": "^9.0.0", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
safe-outputsblock is well-structured. Theupload-artifactconfig withretention-days: 1andmax-uploads: 1is appropriately scoped for a smoke test workflow — avoids unnecessary artifact accumulation.