Skip to content

Commit 2e12cb8

Browse files
gambe94claude
andauthored
chore: standardize Claude Code setup + retarget CI to main (#4)
* chore: standardize Claude Code setup — skills, settings, tooling docs Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * ci: retarget workflows and docs from develop to main Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 1ce2f8e commit 2e12cb8

5 files changed

Lines changed: 349 additions & 1 deletion

File tree

Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
---
2+
name: github-actions-templates
3+
description: Create production-ready GitHub Actions workflows for automated testing, building, and deploying applications. Use when setting up CI/CD with GitHub Actions, automating development workflows, or creating reusable workflow templates.
4+
---
5+
6+
# GitHub Actions Templates
7+
8+
Production-ready GitHub Actions workflow patterns for testing, building, and deploying applications.
9+
10+
## Purpose
11+
12+
Create efficient, secure GitHub Actions workflows for continuous integration and deployment across various tech stacks.
13+
14+
## When to Use
15+
16+
- Automate testing and deployment
17+
- Build Docker images and push to registries
18+
- Deploy to Kubernetes clusters
19+
- Run security scans
20+
- Implement matrix builds for multiple environments
21+
22+
## Common Workflow Patterns
23+
24+
### Pattern 1: Test Workflow
25+
26+
```yaml
27+
name: Test
28+
29+
on:
30+
push:
31+
branches: [main, develop]
32+
pull_request:
33+
branches: [main]
34+
35+
jobs:
36+
test:
37+
runs-on: ubuntu-latest
38+
39+
strategy:
40+
matrix:
41+
node-version: [18.x, 20.x]
42+
43+
steps:
44+
- uses: actions/checkout@v4
45+
46+
- name: Use Node.js ${{ matrix.node-version }}
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
cache: "npm"
51+
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Run linter
56+
run: npm run lint
57+
58+
- name: Run tests
59+
run: npm test
60+
61+
- name: Upload coverage
62+
uses: codecov/codecov-action@v4
63+
with:
64+
files: ./coverage/lcov.info
65+
```
66+
67+
**Reference:** See `assets/test-workflow.yml`
68+
69+
### Pattern 2: Build and Push Docker Image
70+
71+
```yaml
72+
name: Build and Push
73+
74+
on:
75+
push:
76+
branches: [main]
77+
tags: ["v*"]
78+
79+
env:
80+
REGISTRY: ghcr.io
81+
IMAGE_NAME: ${{ github.repository }}
82+
83+
jobs:
84+
build:
85+
runs-on: ubuntu-latest
86+
permissions:
87+
contents: read
88+
packages: write
89+
90+
steps:
91+
- uses: actions/checkout@v4
92+
93+
- name: Log in to Container Registry
94+
uses: docker/login-action@v3
95+
with:
96+
registry: ${{ env.REGISTRY }}
97+
username: ${{ github.actor }}
98+
password: ${{ secrets.GITHUB_TOKEN }}
99+
100+
- name: Extract metadata
101+
id: meta
102+
uses: docker/metadata-action@v5
103+
with:
104+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
105+
tags: |
106+
type=ref,event=branch
107+
type=ref,event=pr
108+
type=semver,pattern={{version}}
109+
type=semver,pattern={{major}}.{{minor}}
110+
111+
- name: Build and push
112+
uses: docker/build-push-action@v5
113+
with:
114+
context: .
115+
push: true
116+
tags: ${{ steps.meta.outputs.tags }}
117+
labels: ${{ steps.meta.outputs.labels }}
118+
cache-from: type=gha
119+
cache-to: type=gha,mode=max
120+
```
121+
122+
**Reference:** See `assets/deploy-workflow.yml`
123+
124+
### Pattern 3: Deploy to Kubernetes
125+
126+
```yaml
127+
name: Deploy to Kubernetes
128+
129+
on:
130+
push:
131+
branches: [main]
132+
133+
jobs:
134+
deploy:
135+
runs-on: ubuntu-latest
136+
137+
steps:
138+
- uses: actions/checkout@v4
139+
140+
- name: Configure AWS credentials
141+
uses: aws-actions/configure-aws-credentials@v4
142+
with:
143+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
144+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
145+
aws-region: us-west-2
146+
147+
- name: Update kubeconfig
148+
run: |
149+
aws eks update-kubeconfig --name production-cluster --region us-west-2
150+
151+
- name: Deploy to Kubernetes
152+
run: |
153+
kubectl apply -f k8s/
154+
kubectl rollout status deployment/my-app -n production
155+
kubectl get services -n production
156+
157+
- name: Verify deployment
158+
run: |
159+
kubectl get pods -n production
160+
kubectl describe deployment my-app -n production
161+
```
162+
163+
### Pattern 4: Matrix Build
164+
165+
```yaml
166+
name: Matrix Build
167+
168+
on: [push, pull_request]
169+
170+
jobs:
171+
build:
172+
runs-on: ${{ matrix.os }}
173+
174+
strategy:
175+
matrix:
176+
os: [ubuntu-latest, macos-latest, windows-latest]
177+
python-version: ["3.9", "3.10", "3.11", "3.12"]
178+
179+
steps:
180+
- uses: actions/checkout@v4
181+
182+
- name: Set up Python
183+
uses: actions/setup-python@v5
184+
with:
185+
python-version: ${{ matrix.python-version }}
186+
187+
- name: Install dependencies
188+
run: |
189+
python -m pip install --upgrade pip
190+
pip install -r requirements.txt
191+
192+
- name: Run tests
193+
run: pytest
194+
```
195+
196+
**Reference:** See `assets/matrix-build.yml`
197+
198+
## Workflow Best Practices
199+
200+
1. **Use specific action versions** (@v4, not @latest)
201+
2. **Cache dependencies** to speed up builds
202+
3. **Use secrets** for sensitive data
203+
4. **Implement status checks** on PRs
204+
5. **Use matrix builds** for multi-version testing
205+
6. **Set appropriate permissions**
206+
7. **Use reusable workflows** for common patterns
207+
8. **Implement approval gates** for production
208+
9. **Add notification steps** for failures
209+
10. **Use self-hosted runners** for sensitive workloads
210+
211+
## Reusable Workflows
212+
213+
```yaml
214+
# .github/workflows/reusable-test.yml
215+
name: Reusable Test Workflow
216+
217+
on:
218+
workflow_call:
219+
inputs:
220+
node-version:
221+
required: true
222+
type: string
223+
secrets:
224+
NPM_TOKEN:
225+
required: true
226+
227+
jobs:
228+
test:
229+
runs-on: ubuntu-latest
230+
steps:
231+
- uses: actions/checkout@v4
232+
- uses: actions/setup-node@v4
233+
with:
234+
node-version: ${{ inputs.node-version }}
235+
- run: npm ci
236+
- run: npm test
237+
```
238+
239+
**Use reusable workflow:**
240+
241+
```yaml
242+
jobs:
243+
call-test:
244+
uses: ./.github/workflows/reusable-test.yml
245+
with:
246+
node-version: "20.x"
247+
secrets:
248+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
249+
```
250+
251+
## Security Scanning
252+
253+
```yaml
254+
name: Security Scan
255+
256+
on:
257+
push:
258+
branches: [main]
259+
pull_request:
260+
branches: [main]
261+
262+
jobs:
263+
security:
264+
runs-on: ubuntu-latest
265+
266+
steps:
267+
- uses: actions/checkout@v4
268+
269+
- name: Run Trivy vulnerability scanner
270+
uses: aquasecurity/trivy-action@0.28.0
271+
with:
272+
scan-type: "fs"
273+
scan-ref: "."
274+
format: "sarif"
275+
output: "trivy-results.sarif"
276+
277+
- name: Upload Trivy results to GitHub Security
278+
uses: github/codeql-action/upload-sarif@v3
279+
with:
280+
sarif_file: "trivy-results.sarif"
281+
282+
- name: Run Snyk Security Scan
283+
uses: snyk/actions/node@0.4.0
284+
env:
285+
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
286+
```
287+
288+
## Deployment with Approvals
289+
290+
```yaml
291+
name: Deploy to Production
292+
293+
on:
294+
push:
295+
tags: ["v*"]
296+
297+
jobs:
298+
deploy:
299+
runs-on: ubuntu-latest
300+
environment:
301+
name: production
302+
url: https://app.example.com
303+
304+
steps:
305+
- uses: actions/checkout@v4
306+
307+
- name: Deploy application
308+
run: |
309+
echo "Deploying to production..."
310+
# Deployment commands here
311+
312+
- name: Notify Slack
313+
if: success()
314+
uses: slackapi/slack-github-action@v1
315+
with:
316+
webhook-url: ${{ secrets.SLACK_WEBHOOK }}
317+
payload: |
318+
{
319+
"text": "Deployment to production completed successfully!"
320+
}
321+
```
322+
323+
324+
## Related Skills
325+
326+
- `gitlab-ci-patterns` - For GitLab CI workflows
327+
- `deployment-pipeline-design` - For pipeline architecture
328+
- `secrets-management` - For secrets handling
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../.agents/skills/github-actions-templates

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: CI
33
on:
44
pull_request:
55
push:
6-
branches: [main, develop]
6+
branches: [main]
77
workflow_dispatch:
88

99
permissions:

CLAUDE.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,16 @@ Invoke the relevant one when the task matches:
9494
| `code-review` | Reviewing TypeScript for quality/correctness (`packages/core` + action adapters). |
9595

9696
Manage with `npx skills check` / `npx skills update`.
97+
98+
<!-- skills-tooling -->
99+
## Skills & AI tooling
100+
101+
**External skills** (lockfile-managed — update with `npx skills check` / `npx skills update`):
102+
- `code-review` — from mattpocock/skills
103+
- `github-actions-docs` — from xixu-me/skills
104+
- `github-actions-templates` — from wshobson/agents
105+
- `receiving-code-review` — from obra/superpowers
106+
- `requesting-code-review` — from obra/superpowers
107+
108+
**Global tooling available in every session:** lean-ctx (prefer `ctx_*` MCP tools for reads/search/shell — token-compressed), superpowers process skills, and graphify (no graph built for this repo).
109+
<!-- /skills-tooling -->

skills-lock.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313
"skillPath": "skills/github-actions-docs/SKILL.md",
1414
"computedHash": "e9ac24e79715ef3060bd4ae376052f8d863b830604e69cb513b39764bf47ee53"
1515
},
16+
"github-actions-templates": {
17+
"source": "wshobson/agents",
18+
"sourceType": "github",
19+
"skillPath": "plugins/cicd-automation/skills/github-actions-templates/SKILL.md",
20+
"computedHash": "93e92fd674dea084628e95f9c48af806f9672ac08f815c84f85adedb55742c59"
21+
},
1622
"receiving-code-review": {
1723
"source": "obra/superpowers",
1824
"sourceType": "github",

0 commit comments

Comments
 (0)