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 3 times, most recently from f5770d9 to dbe9066 Compare January 12, 2026 21:45
@ericsciple ericsciple force-pushed the users/ericsciple/26-01-snippet branch from dbe9066 to f7368c7 Compare January 12, 2026 22:51
@ericsciple ericsciple marked this pull request as ready for review January 12, 2026 23:15
@ericsciple ericsciple requested a review from a team as a code owner January 12, 2026 23:15
Copilot AI review requested due to automatic review settings January 12, 2026 23:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@ericsciple ericsciple merged commit fa27dfa into main Jan 13, 2026
8 of 9 checks passed
@ericsciple ericsciple deleted the users/ericsciple/26-01-snippet branch January 13, 2026 15:14
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.

3 participants