-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatterns.html
More file actions
182 lines (166 loc) · 9.45 KB
/
patterns.html
File metadata and controls
182 lines (166 loc) · 9.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>5 free GitHub Actions cost patterns - depmedic</title>
<meta name="description" content="The first 5 patterns from the Cut Your CI Bill cookbook, free and paste-ready. Concurrency, runner choice, cache, timeout, paths filters. Apply in under an hour." />
<link rel="canonical" href="https://depmedicdev-byte.github.io/patterns.html" />
<meta name="theme-color" content="#0b0d10" />
<meta property="og:title" content="5 free GitHub Actions cost patterns" />
<meta property="og:description" content="The first 5 patterns from the cookbook. Free, paste-ready, MIT. Cuts a typical PR-heavy repo's bill in half." />
<meta property="og:url" content="https://depmedicdev-byte.github.io/patterns.html" />
<meta property="og:type" content="article" />
<meta property="og:image" content="https://depmedicdev-byte.github.io/og/patterns.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://depmedicdev-byte.github.io/og/patterns.png" />
<style>
:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
background: #0b0d10; color: #e6e8eb;
font: 16px/1.6 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
-webkit-font-smoothing: antialiased;
}
a { color: #6cb6ff; text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 820px; margin: 0 auto; padding: 40px 20px 80px; }
.nav { color: #9aa3ad; font-size: 14px; margin: 0 0 16px; }
.nav a { color: #9aa3ad; }
h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 22px; color: #c9d1d9; margin: 36px 0 6px; }
h3 { font-size: 17px; color: #6cb6ff; margin: 18px 0 6px; }
.lead { color: #b6bec7; max-width: 64ch; }
.meta { color: #6f7882; font-size: 14px; margin: 0 0 20px; }
pre { background: #0d1117; border: 1px solid #1e242c; border-radius: 8px; padding: 14px 16px; overflow: auto; }
code { font: 13.5px/1.55 ui-monospace, SFMono-Regular, "Cascadia Mono", Menlo, monospace; color: #c9d1d9; }
p code { background: #11151b; border: 1px solid #1e242c; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.pattern { border: 1px solid #1e242c; border-radius: 10px; padding: 18px 22px; margin: 22px 0; background: #0d1117; }
.pattern h2 { margin-top: 0; font-size: 19px; color: #e6e8eb; }
.label { display: inline-block; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #6cb6ff; margin-right: 6px; }
.promo {
margin: 36px 0; padding: 22px 24px; border-radius: 10px;
background: linear-gradient(135deg, #11151b, #0e1b1c); border: 1px solid #2a4732;
}
.promo h3 { margin-top: 0; color: #e6e8eb; font-size: 19px; }
.promo .price { color: #9aa3ad; font-size: 13px; margin-left: 8px; }
.btn {
display: inline-block; padding: 10px 18px; border-radius: 6px; margin-top: 8px;
background: #2a3744; color: #e6e8eb; font-weight: 500; border: 1px solid #3a4754;
}
.btn:hover { text-decoration: none; background: #3a4754; }
footer { margin-top: 48px; color: #6f7882; font-size: 13px; border-top: 1px solid #1e242c; padding-top: 16px; }
.grid-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 14px 0; }
.grid-cta a { display: block; padding: 12px 14px; background: #11151b; border: 1px solid #1e242c; border-radius: 8px; color: #c9d1d9; }
.grid-cta a:hover { background: #161b22; text-decoration: none; }
.grid-cta a strong { color: #e6e8eb; }
@media (max-width: 600px) { .grid-cta { grid-template-columns: 1fr; } }
</style>
</head>
<body>
<main>
<p class="nav"><a href="/">depmedic</a> / patterns</p>
<h1>5 free GitHub Actions cost patterns</h1>
<p class="meta">The first 5 patterns from the Cut Your CI Bill cookbook. Paste-ready, MIT-licensed.</p>
<p class="lead">
These are the highest-impact patterns. If you apply only these five, a
typical PR-heavy repo's monthly Actions bill drops by roughly half.
No tools required to apply them - they are YAML edits.
</p>
<div class="grid-cta">
<a href="/audit.html"><strong>Audit a workflow</strong><br />Find which of these patterns are missing in your YAML.</a>
<a href="/budget.html"><strong>Price a workflow</strong><br />See the dollar number before and after applying these.</a>
</div>
<div class="pattern">
<h2>1. Cancel superseded runs with concurrency</h2>
<p><span class="label">Why</span> Without a concurrency block, a fast push-to-push-to-push streak runs CI three times for the same final state. On a busy repo with 50 pushes/day this is the single biggest leak.</p>
<p><span class="label">Apply</span> Top of every workflow that runs on <code>push</code> or <code>pull_request</code>:</p>
<pre><code>concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true</code></pre>
<p><span class="label">Catch</span> For deploy workflows you usually want <code>cancel-in-progress: false</code> so a deploy in progress finishes; concurrency just queues the next one.</p>
</div>
<div class="pattern">
<h2>2. Use <code>ubuntu-latest</code> unless you genuinely need macOS or Windows</h2>
<p><span class="label">Why</span> <code>macos-latest</code> runs 10x the cost. <code>windows-latest</code> 2x. A test job that "happens to be" on macOS doubles or worse the bill of every PR.</p>
<p><span class="label">Apply</span> Audit <code>runs-on:</code> lines. macOS is required only when you build or sign Apple binaries (<code>xcodebuild</code>, <code>codesign</code>, <code>notarytool</code>). Windows is required only for native Windows code paths.</p>
<p><span class="label">Catch</span> Cross-platform tests should still exist. Move them to a nightly schedule or a <code>workflow_dispatch</code> job rather than running every PR.</p>
</div>
<div class="pattern">
<h2>3. Cache language tooling</h2>
<p><span class="label">Why</span> Without <code>cache:</code>, <code>setup-node</code>, <code>setup-python</code>, <code>setup-java</code>, <code>setup-go</code>, and <code>setup-dotnet</code> re-download dependencies on every run. 30 to 90 seconds per job, sometimes more.</p>
<p><span class="label">Apply</span></p>
<pre><code>- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip</code></pre>
<p><span class="label">Catch</span> Cache keys depend on lockfiles. If the lockfile path is non-standard, set <code>cache-dependency-path</code>.</p>
</div>
<div class="pattern">
<h2>4. Set <code>timeout-minutes</code> on every job</h2>
<p><span class="label">Why</span> The default is 360 minutes (6 hours). A hung step burns six hours of paid runner time before GitHub kills it.</p>
<p><span class="label">Apply</span> On every job:</p>
<pre><code>jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15</code></pre>
<p><span class="label">Catch</span> Tune per job. Long-running builds deserve more headroom; tests deserve less.</p>
</div>
<div class="pattern">
<h2>5. <code>paths:</code> filters on heavy workflows</h2>
<p><span class="label">Why</span> A 20-minute integration suite has no business running when a PR only touched the README.</p>
<p><span class="label">Apply</span></p>
<pre><code>on:
pull_request:
paths:
- 'src/**'
- 'tests/**'
- 'package.json'
- 'package-lock.json'</code></pre>
<p><span class="label">Catch</span> Branch-protection rules that require this workflow won't see a status if it skips. Use <code>paths-ignore</code> to skip the workflow entirely, or keep a "always run" stub job that posts a green status when the heavy job isn't needed.</p>
</div>
<h2>Auto-apply patterns 1, 4 (and others)</h2>
<p>
Patterns 1 and 4 above (concurrency and timeouts) are two of the four that
<a href="https://www.npmjs.com/package/ci-doctor"><code>ci-doctor --fix</code></a>
applies for you, in place. Free, MIT, no signup.
</p>
<pre><code>npx ci-doctor --fix --dry-run # preview the patches
npx ci-doctor --fix # apply</code></pre>
<h2>Get the other 25 patterns</h2>
<div class="promo">
<h3>The full Cut Your CI Bill cookbook</h3>
<p>
30 patterns total - cost, speed, security, maintenance - plus 5
paste-ready hardened workflow templates (CI, release, security scan,
nightly, deploy). All MIT-licensed templates, lifetime updates.
<span class="price">$19, one-time.</span>
</p>
<p>
The cookbook covers what the patterns above stop short of: matrix
sizing, artifact retention strategy, draft-PR skipping, OIDC for cloud
auth, reusable workflows, dependabot grouping, and the security
patterns (least-privilege permissions, SHA pinning, untrusted-input
handling).
</p>
<a class="btn" href="https://buy.polar.sh/polar_cl_E2HGFeAVxJ64gU0Tv0qGwAueuxvhuq6A0pjhE4BWTyD" rel="noopener">Get the cookbook</a>
</div>
<h2>See also</h2>
<ul>
<li><a href="/benchmarks.html">CI cost benchmarks</a> - 20 popular OSS projects, 902 real findings, modeled monthly cost.</li>
<li><a href="/blog/oss-ci-cost-benchmarks.html">Blog post on the dataset</a> - how the numbers were generated.</li>
<li><a href="/blog/stop-linting-github-actions.html">Stop linting your GitHub Actions, fix them</a> - <code>ci-doctor --fix</code> deep dive.</li>
</ul>
<footer>
<a href="/">Back to depmedic.</a>
</footer>
</main>
</body>
</html>