⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Conversation

@ericsciple
Copy link
Collaborator

@ericsciple ericsciple commented Jan 10, 2026

Problem

Creating a new GitHub Action requires writing boilerplate YAML. Users have to remember the correct structure for action.yml files, which differs based on whether they're building a Node.js, Composite, or Docker action.

Solution

When editing an action.yml file without a runs.using value, the language service now offers three scaffolding snippets:

  • Node.js Action — Creates a complete action with using: node24
  • Composite Action — Creates a complete action with shell steps
  • Docker Action — Creates a complete action with container configuration

Each snippet includes:

  • Name and description placeholders
  • A sample input with description, required flag, and default value
  • A sample output
  • A working "hello world" implementation

Behavior

Empty file or no runs: block: Offers full scaffolding snippets with name, description, inputs, outputs, and runs.

File already has name: or description:: Offers runs-only snippets that just fill in the runs: block.

Inside runs: without using:: Offers all three action type snippets.

Once runs.using is set: Snippets no longer appear (scaffolding is complete).

import {defaultValueProviders} from "./value-providers/default.js";
import {DefinitionValueMode, definitionValues, TokenStructure} from "./value-providers/definition.js";

/**
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to complete-action.ts since this is specific to action.yml

// = 32 + 11 = 43
return lengthOfContentBeforeCurrentLine + pos.character;
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved to complete-action.ts since this is specific to action.yml

* Valid keys for each action type under the `runs:` section.
* Source: https://github.com/actions/runner/blob/main/src/Runner.Worker/ActionManifestManager.cs
*/
const ACTION_NODE_KEYS = new Set(["using", "main", "pre", "post", "pre-if", "post-if"]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These three consts aren't new. They were moved from complete.ts

* Full variants include name, description, inputs, outputs, and runs.
* Runs-only variants include just the runs block.
*/
const ACTION_SNIPPET_NODEJS_FULL = `name: '\${1:Action Name}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodejs action snippet with name and description since those are required fields

# https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-javascript-action
`;

const ACTION_SNIPPET_NODEJS_RUNS = `inputs:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodejs action snippet without name and description (used when either name or description already exists at the root of the file)

# fs.appendFileSync(process.env.GITHUB_OUTPUT, \\\`greeting=\\\${greeting}\\\\n\\\`);
`;

const ACTION_SNIPPET_NODEJS_USING = `# For more on JavaScript actions (including @actions/toolkit), see:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nodejs action snippet if the cursor is under runs, e.g.

runs:
  |

# console.log('Hello World');
`;

const ACTION_SNIPPET_COMPOSITE_FULL = `name: '\${1:Action Name}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composite action

run: echo "Hello World"
`;

const ACTION_SNIPPET_DOCKER_FULL = `name: '\${1:Action Name}'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docker action

* - If `using: docker` is set, only show Docker action keys
* - If `using:` is not set, show all keys but prioritize `using` first
*/
export function filterActionRunsCompletions(values: Value[], path: TemplateToken[], root: TemplateToken): Value[] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function isn't new. This simply moved from complete.ts into this new file, since it's specific to action.yml only

@ericsciple ericsciple force-pushed the users/ericsciple/26-01-snippet branch from 40c44dc to 120eda1 Compare January 11, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants