@lekman/devops-toolkit-tasks 1.4.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +101 -42
- package/dist/build.js +499 -0
- package/dist/help.js +151 -0
- package/dist/register.js +1273 -0
- package/package.json +29 -20
- package/tasks/core.yml +45 -0
- package/tasks/package.yml +28 -0
- package/common/ai.yml +0 -106
- package/common/aws.yml +0 -41
- package/common/docker.yml +0 -68
- package/common/git.yml +0 -295
- package/common/modules.yml +0 -41
- package/common/security.yml +0 -22
- package/docs/README.md +0 -238
package/common/security.yml
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
version: "3"
|
|
2
|
-
|
|
3
|
-
vars:
|
|
4
|
-
DOCKER_SOCKET: /var/run/docker.sock
|
|
5
|
-
TRIVY_IMAGE: aquasec/trivy:latest
|
|
6
|
-
DEFAULT_SEVERITY: "HIGH,CRITICAL"
|
|
7
|
-
|
|
8
|
-
tasks:
|
|
9
|
-
# Scan a Docker image for vulnerabilities
|
|
10
|
-
scan-image:
|
|
11
|
-
desc: Scan a Docker image for vulnerabilities using Trivy
|
|
12
|
-
silent: true
|
|
13
|
-
vars:
|
|
14
|
-
IMAGE_NAME:
|
|
15
|
-
sh: echo "{{.IMAGE_NAME}}"
|
|
16
|
-
IMAGE_TAG:
|
|
17
|
-
sh: echo "{{.IMAGE_TAG}}"
|
|
18
|
-
SEVERITY:
|
|
19
|
-
sh: echo "{{.SEVERITY | default .DEFAULT_SEVERITY}}"
|
|
20
|
-
cmds:
|
|
21
|
-
- echo "Scanning image {{.IMAGE_NAME}}:{{.IMAGE_TAG}} for {{.SEVERITY}} vulnerabilities"
|
|
22
|
-
- docker run -v {{.DOCKER_SOCKET}}:{{.DOCKER_SOCKET}} {{.TRIVY_IMAGE}} image --severity {{.SEVERITY}} {{.IMAGE_NAME}}:{{.IMAGE_TAG}}
|
package/docs/README.md
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
# DevOps Toolkit Tasks
|
|
2
|
-
|
|
3
|
-
A collection of reusable task modules for common DevOps operations, built with [GoTask](https://taskfile.dev/). These modules provide a standardized way to perform common operations across different projects.
|
|
4
|
-
|
|
5
|
-
## Purpose
|
|
6
|
-
|
|
7
|
-
These task modules are designed to streamline common DevOps operations by providing:
|
|
8
|
-
|
|
9
|
-
- Standardized commands for common operations
|
|
10
|
-
- Consistent behavior across different projects
|
|
11
|
-
- Reusable components that can be shared between projects
|
|
12
|
-
- Simplified automation of routine tasks
|
|
13
|
-
|
|
14
|
-
The modules cover various aspects of development workflow including:
|
|
15
|
-
|
|
16
|
-
- AWS operations (ECR, authentication)
|
|
17
|
-
- Docker operations (build, tag, push)
|
|
18
|
-
- Git operations (branch management, hooks)
|
|
19
|
-
- Security scanning
|
|
20
|
-
- Module management
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
1. Base `gotask` install
|
|
25
|
-
|
|
26
|
-
You only need to install `gotask` once on your machine.
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
brew install go-task/tap/go-task
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
2. Install the shared tasks package (published on npmjs.org, no auth needed):
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm i -D @lekman/devops-toolkit-tasks@latest
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
3. Set up your taskfile.yml
|
|
39
|
-
|
|
40
|
-
To use these tasks in your project, you can import the libaries in your `taskfile.yml` added to the root of your project:
|
|
41
|
-
|
|
42
|
-
The basic taskfile should look like this:
|
|
43
|
-
|
|
44
|
-
```yaml
|
|
45
|
-
version: "3"
|
|
46
|
-
|
|
47
|
-
includes:
|
|
48
|
-
ai: node_modules/@lekman/devops-toolkit-tasks/common/ai.yml
|
|
49
|
-
aws: node_modules/@lekman/devops-toolkit-tasks/common/aws.yml
|
|
50
|
-
docker: node_modules/@lekman/devops-toolkit-tasks/common/docker.yml
|
|
51
|
-
git: node_modules/@lekman/devops-toolkit-tasks/common/git.yml
|
|
52
|
-
modules: node_modules/@lekman/devops-toolkit-tasks/common/modules.yml
|
|
53
|
-
security: node_modules/@lekman/devops-toolkit-tasks/common/security.yml
|
|
54
|
-
|
|
55
|
-
tasks:
|
|
56
|
-
# Default task that shows available commands
|
|
57
|
-
default:
|
|
58
|
-
silent: true
|
|
59
|
-
cmds:
|
|
60
|
-
- task --list
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Available Tasks
|
|
64
|
-
|
|
65
|
-
### AI Tasks
|
|
66
|
-
|
|
67
|
-
| Task | Description | Alias |
|
|
68
|
-
| ---------- | ------------------------------------------------------------------------------- | ----- |
|
|
69
|
-
| `ai:setup` | Setup AI development tools (Claude, Codex, Cursor, GitHub Copilot, Task Master) | - |
|
|
70
|
-
|
|
71
|
-
### AWS Tasks
|
|
72
|
-
|
|
73
|
-
| Task | Description | Alias |
|
|
74
|
-
| --------------------------- | ----------------------------------------- | ----- |
|
|
75
|
-
| `aws:check-auth` | Check AWS authentication | - |
|
|
76
|
-
| `aws:configure-docker` | Configure Docker to use AWS credentials | - |
|
|
77
|
-
| `aws:ensure-ecr-repository` | Create ECR repository if it doesn't exist | - |
|
|
78
|
-
|
|
79
|
-
### Docker Tasks
|
|
80
|
-
|
|
81
|
-
| Task | Description | Alias |
|
|
82
|
-
| ------------------------------ | ------------------------------------------------- | ----- |
|
|
83
|
-
| `docker:ensure-docker-running` | Check if Docker is running and start it if needed | - |
|
|
84
|
-
| `docker:build-image` | Build a Docker image | - |
|
|
85
|
-
| `docker:tag-image` | Tag a Docker image | - |
|
|
86
|
-
| `docker:push-image` | Push a Docker image to registry | - |
|
|
87
|
-
|
|
88
|
-
### Git Tasks
|
|
89
|
-
|
|
90
|
-
| Task | Description | Alias |
|
|
91
|
-
| -------------------- | ------------------------------------------------------------- | ------------------------------- |
|
|
92
|
-
| `git:cd-root` | Change to the repository root directory | - |
|
|
93
|
-
| `git:get-root` | Get the absolute path to the repository root | - |
|
|
94
|
-
| `git:prune` | Delete local branches that don't have a remote counterpart | `git:clean-branches`, `git:clb` |
|
|
95
|
-
| `git:fetch-prune` | Fetch and prune remote branches | `git:fp` |
|
|
96
|
-
| `git:switch-default` | Switch to the default branch | `git:sd` |
|
|
97
|
-
| `git:list-branches` | List all branches with their status | `git:lb` |
|
|
98
|
-
| `git:delete-runs` | Delete GitHub workflow runs for a branch with specific status | `git:dr` |
|
|
99
|
-
| `git:hooks:setup` | Set up git hooks with Jira integration | `git:hs` |
|
|
100
|
-
| `git:hooks:remove` | Remove git hooks configuration | `git:hr` |
|
|
101
|
-
| `git:hooks:status` | Show git hooks configuration status | `git:hst` |
|
|
102
|
-
|
|
103
|
-
### Module Tasks
|
|
104
|
-
|
|
105
|
-
| Task | Description | Alias |
|
|
106
|
-
| ---------------------- | --------------------------------------------------------- | ------------ |
|
|
107
|
-
| `modules:update-tools` | Update @lekman/devops-toolkit-tasks to the latest version | `modules:ut` |
|
|
108
|
-
|
|
109
|
-
### Security Tasks
|
|
110
|
-
|
|
111
|
-
| Task | Description | Alias |
|
|
112
|
-
| --------------------- | --------------------------------------------------- | ----- |
|
|
113
|
-
| `security:scan-image` | Scan a Docker image for vulnerabilities using Trivy | - |
|
|
114
|
-
|
|
115
|
-
## Creating Custom Tasks
|
|
116
|
-
|
|
117
|
-
You can create custom tasks that depend on shared tasks and add your own logic. Here's an example of how to create a custom task that:
|
|
118
|
-
|
|
119
|
-
1. Ensures Docker is running (using shared task)
|
|
120
|
-
2. Performs custom logic
|
|
121
|
-
3. Uses another shared task
|
|
122
|
-
|
|
123
|
-
```yaml
|
|
124
|
-
version: "3"
|
|
125
|
-
|
|
126
|
-
includes:
|
|
127
|
-
docker: node_modules/@lekman/devops-toolkit-tasks/common/docker.yml
|
|
128
|
-
security: node_modules/@lekman/devops-toolkit-tasks/common/security.yml
|
|
129
|
-
|
|
130
|
-
tasks:
|
|
131
|
-
# Custom task that builds and scans an image
|
|
132
|
-
build-and-scan:
|
|
133
|
-
desc: Build a Docker image and scan it for vulnerabilities
|
|
134
|
-
silent: true # Reduces noise in output, only shows important messages
|
|
135
|
-
deps: [docker:ensure-docker-running] # Ensure Docker is running first
|
|
136
|
-
vars:
|
|
137
|
-
IMAGE_NAME: "{{.IMAGE_NAME}}"
|
|
138
|
-
IMAGE_TAG: '{{.IMAGE_TAG | default "latest"}}'
|
|
139
|
-
DOCKERFILE_PATH: '{{.DOCKERFILE_PATH | default "."}}'
|
|
140
|
-
cmds:
|
|
141
|
-
# Custom build logic
|
|
142
|
-
- echo "Building custom image..."
|
|
143
|
-
- docker build -t {{.IMAGE_NAME}}:{{.IMAGE_TAG}} {{.DOCKERFILE_PATH}}
|
|
144
|
-
|
|
145
|
-
# Run security scan using shared task
|
|
146
|
-
- task: security:scan-image
|
|
147
|
-
vars:
|
|
148
|
-
IMAGE_NAME: "{{.IMAGE_NAME}}"
|
|
149
|
-
IMAGE_TAG: "{{.IMAGE_TAG}}"
|
|
150
|
-
SEVERITY: "HIGH,CRITICAL"
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
You can run this custom task with:
|
|
154
|
-
|
|
155
|
-
```bash
|
|
156
|
-
task build-and-scan IMAGE_NAME=myapp IMAGE_TAG=v1.0 DOCKERFILE_PATH=./docker
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
The task will:
|
|
160
|
-
|
|
161
|
-
1. First ensure Docker is running (using the shared `docker:ensure-docker-running` task)
|
|
162
|
-
2. Execute the custom build commands
|
|
163
|
-
3. Run the security scan using the shared `security:scan-image` task
|
|
164
|
-
|
|
165
|
-
This pattern allows you to:
|
|
166
|
-
|
|
167
|
-
- Reuse existing functionality from shared tasks
|
|
168
|
-
- Add your own custom logic
|
|
169
|
-
- Ensure proper task dependencies
|
|
170
|
-
- Keep your taskfile DRY (Don't Repeat Yourself)
|
|
171
|
-
|
|
172
|
-
### Best Practices
|
|
173
|
-
|
|
174
|
-
#### Using the Silent Flag
|
|
175
|
-
|
|
176
|
-
The `silent: true` flag is a best practice for several reasons:
|
|
177
|
-
|
|
178
|
-
1. **Cleaner Output**: It reduces noise in the terminal by hiding the command being executed, showing only the actual output
|
|
179
|
-
2. **Better Readability**: Makes it easier to spot important messages and errors
|
|
180
|
-
3. **Consistent Experience**: When chaining multiple tasks, it prevents command echo from each task
|
|
181
|
-
4. **Professional Look**: The output looks more polished and professional
|
|
182
|
-
5. **Easier Debugging**: When something goes wrong, the error messages stand out more clearly
|
|
183
|
-
|
|
184
|
-
You can still see the full command output by running the task with the `--verbose` flag:
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
task build-and-scan --verbose
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
This is particularly useful when debugging or when you need to see exactly what commands are being executed.
|
|
191
|
-
|
|
192
|
-
### Task Organization
|
|
193
|
-
|
|
194
|
-
- **Keep it Modular**: Use separate task files for different concerns
|
|
195
|
-
- **Use Shared Tasks**: Leverage our shared task definitions
|
|
196
|
-
- **Follow Naming**: Use consistent naming conventions
|
|
197
|
-
- **Document Tasks**: Always include descriptions
|
|
198
|
-
|
|
199
|
-
### Task Dependencies
|
|
200
|
-
|
|
201
|
-
- Use dependencies to ensure prerequisites are met
|
|
202
|
-
- Keep dependency chains short and clear
|
|
203
|
-
- Use silent mode for cleaner output
|
|
204
|
-
|
|
205
|
-
### Error Handling
|
|
206
|
-
|
|
207
|
-
- Add proper error messages
|
|
208
|
-
- Use exit codes appropriately
|
|
209
|
-
- Handle edge cases
|
|
210
|
-
|
|
211
|
-
### Version Management
|
|
212
|
-
|
|
213
|
-
- Pin to specific versions of shared tasks
|
|
214
|
-
- Document breaking changes
|
|
215
|
-
- Use semantic versioning
|
|
216
|
-
|
|
217
|
-
## Troubleshooting
|
|
218
|
-
|
|
219
|
-
### Common Issues
|
|
220
|
-
|
|
221
|
-
1. **Task Not Found**
|
|
222
|
-
- Check task name spelling
|
|
223
|
-
- Verify task file is included
|
|
224
|
-
- Check task dependencies
|
|
225
|
-
|
|
226
|
-
2. **Permission Issues**
|
|
227
|
-
- Ensure scripts are executable
|
|
228
|
-
- Check file permissions
|
|
229
|
-
- Verify user permissions
|
|
230
|
-
|
|
231
|
-
3. **Variable Issues**
|
|
232
|
-
- Check variable definitions
|
|
233
|
-
- Verify variable scope
|
|
234
|
-
- Check default values
|
|
235
|
-
|
|
236
|
-
## Additional Resources
|
|
237
|
-
|
|
238
|
-
- [Go Task Documentation](https://taskfile.dev/)
|