-
Notifications
You must be signed in to change notification settings - Fork 52
Add action.yml scaffolding snippets #296
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?
Conversation
| import {defaultValueProviders} from "./value-providers/default.js"; | ||
| import {DefinitionValueMode, definitionValues, TokenStructure} from "./value-providers/definition.js"; | ||
|
|
||
| /** |
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.
Moved to complete-action.ts since this is specific to action.yml
| // = 32 + 11 = 43 | ||
| return lengthOfContentBeforeCurrentLine + pos.character; | ||
| } | ||
|
|
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.
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"]); |
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.
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}' |
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.
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: |
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.
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: |
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.
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}' |
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.
composite action
| run: echo "Hello World" | ||
| `; | ||
|
|
||
| const ACTION_SNIPPET_DOCKER_FULL = `name: '\${1:Action Name}' |
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.
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[] { |
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.
This function isn't new. This simply moved from complete.ts into this new file, since it's specific to action.yml only
40c44dc to
120eda1
Compare
Problem
Creating a new GitHub Action requires writing boilerplate YAML. Users have to remember the correct structure for
action.ymlfiles, which differs based on whether they're building a Node.js, Composite, or Docker action.Solution
When editing an
action.ymlfile without aruns.usingvalue, the language service now offers three scaffolding snippets:using: node24Each snippet includes:
Behavior
Empty file or no
runs:block: Offers full scaffolding snippets with name, description, inputs, outputs, and runs.File already has
name:ordescription:: Offers runs-only snippets that just fill in theruns:block.Inside
runs:withoutusing:: Offers all three action type snippets.Once
runs.usingis set: Snippets no longer appear (scaffolding is complete).