A curated collection of Visual Studio Code snippets that speed up writing GitHub Actions and workflow YAML files. These snippets provide ready-made templates, property options, and placeholders so you can create valid, consistent CI/CD configurations quickly.
./.vscode/github-actions.code-snippetsβ VS Code snippet definitions.
-
Copy (or symlink)
./.vscode/github-actions.code-snippetsinto your project's.vscode/folder. -
Reload VS Code (Command Palette β "Developer: Reload Window").
-
Open a
.ymlor.yamlfile and start typing a snippet prefix (for examplegha-) or pressCtrl+Spaceto view completions.Notes
- Snippets are scoped for YAML. Ensure the current file language in VS Code is set to YAML if suggestions don't appear.
- Recommended extensions (see
.vscode/extensions.json):ms-vscode.vscode-github-actions,redhat.vscode-yaml.
Use the snippet prefix in a YAML file to insert each template and tab through placeholders.
gha-workflowβ Workflow boilerplate with push/pull_request triggers and a simple build job.gha-workflow-jobβ Job skeleton withruns-onand common steps.gha-workflow-job-step-runβrunstep with optionalif,env,shell, andworking-directoryplaceholders.gha-workflow-job-step-usesβusesstep for running an action.gha-composite-actionβ Composite Action template (inputs, outputs, steps).gha-composite-action-step-runβrunstep for composite actions.gha-composite-action-step-usesβusesstep for composite actions.gha-docker-actionβ Docker-based Action template.gha-node-actionβ Node.js Action template (Node 20.x recommended).gha-action-brandingβ Insertbranding:fields (color, icon) for action metadata.gha-action-step-envβ Insert commonly used GitHub Action environment variables for a step.
For a complete list, open ./.vscode/github-actions.code-snippets and search for "prefix": entries.
-
Create
.github/workflows/ci.yml. -
In VS Code, open it, type
gha-workflow, accept the snippet, then fill placeholders.Snippet expansion example (illustrative):
name: CI on: push: pull_request: jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '20' - name: Install run: npm install - name: Test run: npm test
The repository includes a GitHub workflow that validates the snippets JSON. Locally you can validate the file with jq:
jq empty .vscode/github-actions.code-snippetsA non-zero exit code indicates invalid JSON.
Contributions are welcome. Please read CONTRIBUTING.md for details. Quick guidelines:
- Use the
gha-prefix for new snippets. - Keep snippet bodies valid YAML where applicable.
- Add clear descriptions and set snippet scope to
yamlwhen relevant. - Update
README.mdwhen adding or changing public snippets.
- Run the
jqJSON validation locally. - Open a branch and create a Pull Request β the repository CI will validate the snippets file.
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details.
Open an issue or pull request with suggestions, fixes, or new snippets.