You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/github-action.md
+149Lines changed: 149 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ Complete guide to integrating Socket Basics into your GitHub Actions workflows f
5
5
## Table of Contents
6
6
7
7
-[Quick Start](#quick-start)
8
+
-[Performance and Caching](#performance-and-caching)
8
9
-[Basic Configuration](#basic-configuration)
9
10
-[Enterprise Features](#enterprise-features)
10
11
-[Advanced Workflows](#advanced-workflows)
@@ -52,6 +53,154 @@ jobs:
52
53
53
54
With just your `SOCKET_SECURITY_API_KEY`, all scanning configurations are managed through the [Socket Dashboard](https://socket.dev/dashboard) — no workflow changes needed.
54
55
56
+
## Performance and Caching
57
+
58
+
### How the action is currently built
59
+
60
+
When you reference `uses: SocketDev/socket-basics@1.1.3`, GitHub Actions builds the
61
+
`Dockerfile`from source at the start of every workflow run. As of `1.1.3` the
62
+
Dockerfile uses a **multi-stage build** with BuildKit cache mounts, which provides
63
+
two categories of improvement:
64
+
65
+
| Improvement | Benefit |
66
+
|-------------|---------|
67
+
| Multi-stage stages (`trivy`, `trufflehog`, etc.) | GitHub's runner cache can reuse unchanged tool layers across runs |
68
+
| `python:3.12-slim` base | ~850 MB smaller final image → faster layer pulls on cold runners |
69
+
| `--mount=type=cache` for apt / uv / npm | Faster repeated builds locally and on self-hosted runners with a persistent cache |
70
+
71
+
**On standard GitHub-hosted runners** (ephemeral, no persistent Docker cache between
72
+
jobs), the multi-stage improvement is most visible when the same runner picks up a
73
+
cached layer — typically within a workflow run or when GitHub's runner image itself
74
+
includes the base layers. Cold runs still download and run all tool-install steps.
75
+
76
+
### Pre-built image (active as of 1.1.3)
77
+
78
+
The action now references a pre-built GHCR image instead of building from source:
Users who pin to a specific version tag (e.g. `@1.1.3`) will see the action start
88
+
in seconds rather than minutes — the image is pre-built, integration-tested, and
89
+
published to GHCR before the release tag is ever created.
90
+
91
+
> **Note for `1.1.3` specifically:** the first time you use this version after this
92
+
> change, the `publish-docker.yml` workflow must have run at least once (via
93
+
> `workflow_dispatch` with tag `1.1.3`) to populate the GHCR image. Future releases
94
+
> follow the publish-first process described in the release workflow below.
95
+
96
+
### Release workflow (publish → tag, never tag → publish)
97
+
98
+
To avoid the race condition where a git tag references an image that doesn't exist
99
+
yet, follow this order for every release:
100
+
101
+
```
102
+
1. Merge release PR to main (version bump + action.yml version update)
103
+
2. workflow_dispatch → publish-docker.yml (builds, tests, pushes images to GHCR/DockerHub)
104
+
3. Create git tag (e.g. 1.1.4) — image already exists, zero race condition
105
+
```
106
+
107
+
When users then run `uses: SocketDev/socket-basics@1.1.4`, GitHub reads `action.yml`
108
+
at that tag, pulls `ghcr.io/socketdev/socket-basics:1.1.4`, and starts scanning
109
+
immediately.
110
+
111
+
### If you're running socket-basics outside of the GitHub Action
112
+
113
+
If you run socket-basics in other CI systems (Jenkins, GitLab, CircleCI, etc.) or
114
+
as a standalone `docker run`, pull the pre-built image directly:
115
+
116
+
```bash
117
+
docker pull ghcr.io/socketdev/socket-basics:1.1.3
118
+
```
119
+
120
+
See [Local Docker Installation](local-install-docker.md) for usage examples.
121
+
122
+
### Pinning strategies
123
+
124
+
Starting with v2, socket-basics follows the [GitHub-recommended tag convention](https://docs.github.com/en/actions/sharing-automations/creating-actions/releasing-and-maintaining-actions):
125
+
exact tags (`v2.0.0`), minor tags (`v2.0`), and a floating major tag (`v2`).
126
+
Each strategy offers a different tradeoff between safety and convenience.
127
+
128
+
---
129
+
130
+
**Strategy 1 — Floating major tag: `@v2`**
131
+
132
+
Always runs the latest v2.x.y release. Zero maintenance overhead; you get every
0 commit comments