diff --git a/docs/src/content/docs/reference/command-triggers.md b/docs/src/content/docs/reference/command-triggers.md index ab5205cc925..7e657c6a08e 100644 --- a/docs/src/content/docs/reference/command-triggers.md +++ b/docs/src/content/docs/reference/command-triggers.md @@ -24,6 +24,36 @@ on: on: /my-bot # Ultra-short: slash prefix automatically expands to slash_command + workflow_dispatch ``` +## Multiple Command Identifiers + +A single workflow can respond to multiple slash command names by providing an array of command identifiers: + +```yaml wrap +on: + slash_command: + name: ["cmd.add", "cmd.remove", "cmd.list"] +``` + +When triggered, the matched command is available as `needs.activation.outputs.slash_command`, allowing your workflow to determine which command was used: + +```aw wrap +--- +on: + slash_command: + name: ["summarize", "summary", "tldr"] +permissions: + issues: write +--- + +# Multi-Command Handler + +You invoked the workflow using: `/${{ needs.activation.outputs.slash_command }}` + +Now analyzing the content... +``` + +This feature enables command aliases and grouped command handlers without workflow duplication. + > [!NOTE] > **Deprecated Syntax** > diff --git a/docs/src/content/docs/reference/safe-inputs.md b/docs/src/content/docs/reference/safe-inputs.md index 168e80be72b..3e6b3d16a10 100644 --- a/docs/src/content/docs/reference/safe-inputs.md +++ b/docs/src/content/docs/reference/safe-inputs.md @@ -65,8 +65,9 @@ Choose one implementation method: - **`script:`** - JavaScript (CommonJS) code - **`run:`** - Shell script - **`py:`** - Python script (Python 3.1x) +- **`go:`** - Go (Golang) code -You can only use one of `script:`, `run:`, or `py:` per tool. +You can only use one of `script:`, `run:`, `py:`, or `go:` per tool. ## JavaScript Tools (`script:`) @@ -161,6 +162,63 @@ safe-inputs: Python 3.10+ is available with standard library modules. Install additional packages inline using pip if needed. +## Go Tools (`go:`) + +Go tools execute using `go run` with inputs provided as a `map[string]any` parsed from stdin. Standard library imports (`encoding/json`, `fmt`, `io`, `os`) are automatically included: + +```yaml wrap +safe-inputs: + calculate: + description: "Perform calculations with Go" + inputs: + a: + type: number + required: true + b: + type: number + required: true + go: | + a := inputs["a"].(float64) + b := inputs["b"].(float64) + result := map[string]any{ + "sum": a + b, + "product": a * b, + } + json.NewEncoder(os.Stdout).Encode(result) +``` + +Your Go code receives `inputs map[string]any` from stdin and should output JSON to stdout. The code is wrapped in a `package main` with a `main()` function that handles input parsing. + +**Available by default:** +- `encoding/json` - JSON encoding/decoding +- `fmt` - Formatted I/O +- `io` - I/O primitives +- `os` - Operating system functionality + +Access environment variables (including secrets) using `os.Getenv()`: + +```yaml wrap +safe-inputs: + api-call: + description: "Call an API with Go" + inputs: + endpoint: + type: string + required: true + go: | + apiKey := os.Getenv("API_KEY") + endpoint := inputs["endpoint"].(string) + + // Make your API call here + result := map[string]any{ + "endpoint": endpoint, + "authenticated": apiKey != "", + } + json.NewEncoder(os.Stdout).Encode(result) + env: + API_KEY: "${{ secrets.API_KEY }}" +``` + ## Input Parameters Define typed parameters with validation: