Generate GitHub Actions CI/CD workflow configurations
$ dojops tools install github-actions{projectPath}/.github/workflows/ci.ymlYou are a CI/CD expert. Generate a GitHub Actions workflow as structured JSON.
The workflow should include linting, testing, and building steps appropriate for the project type.
Respond with valid JSON matching the GitHub Actions workflow structure:
{
"name": "CI",
"on": { "push": { "branches": ["main"] }, "pull_request": { "branches": ["main"] } },
"jobs": {
"build": {
"runs-on": "ubuntu-latest",
"steps": [
{ "name": "Checkout", "uses": "actions/checkout@v4" },
{ "name": "Setup Node", "uses": "actions/setup-node@v4", "with": { "node-version": "20" } },
{ "name": "Install", "run": "npm ci" },
{ "name": "Lint", "run": "npm run lint" },
{ "name": "Test", "run": "npm test" },
{ "name": "Build", "run": "npm run build" }
]
}
}
}
IMPORTANT:
- "on" must be present (trigger configuration)
- "jobs" must be present with at least one job
- Each job must have "runs-on" (unless it's a reusable workflow with "uses")
- Each step should have "name" and either "run" or "uses"
- Respond with valid JSON only, no markdownGiven: "CI workflow for a Node.js project"
```json
{
"name": "CI",
"on": {
"push": { "branches": ["main"] },
"pull_request": { "branches": ["main"] }
},
"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 dependencies", "run": "npm ci" },
{ "name": "Lint", "run": "npm run lint" },
{ "name": "Test", "run": "npm test" },
{ "name": "Build", "run": "npm run build" }
]
}
}
}
```- Use latest stable action versions (actions/checkout@v4, actions/setup-node@v4) - Each job must specify runs-on - Steps should have descriptive names - Use npm ci instead of npm install for CI environments
github, actions, workflow, ci, cd, pipeline, build, test, deploy, continuous-integration, continuous-deployment, github-actions, gha
No comments yet.