@codfish/actions 2.0.1 → 3.3.2

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.
Files changed (37) hide show
  1. package/README.md +136 -64
  2. package/bin/generate-docs.js +10 -10
  3. package/comment/README.md +9 -9
  4. package/comment/action.yml +3 -3
  5. package/npm-publish-pr/README.md +320 -40
  6. package/npm-publish-pr/action.yml +271 -87
  7. package/package.json +31 -17
  8. package/setup-node-and-install/README.md +77 -34
  9. package/setup-node-and-install/action.yml +36 -3
  10. package/.github/codeql-config.yml +0 -21
  11. package/.github/dependabot.yml +0 -35
  12. package/.github/workflows/claude-code-review.yml +0 -43
  13. package/.github/workflows/claude.yml +0 -38
  14. package/.github/workflows/release.yml +0 -48
  15. package/.github/workflows/security.yml +0 -103
  16. package/.github/workflows/update-docs.yml +0 -38
  17. package/.github/workflows/validate.yml +0 -210
  18. package/.husky/pre-commit +0 -1
  19. package/.nvmrc +0 -1
  20. package/AGENT.md +0 -149
  21. package/CLAUDE.md +0 -3
  22. package/CONTRIBUTING.md +0 -316
  23. package/SECURITY.md +0 -208
  24. package/eslint.config.js +0 -8
  25. package/tests/fixtures/.node-version +0 -1
  26. package/tests/fixtures/.nvmrc +0 -1
  27. package/tests/fixtures/lockfiles/package-lock.json +0 -12
  28. package/tests/fixtures/lockfiles/pnpm-lock.yaml +0 -9
  29. package/tests/fixtures/lockfiles/yarn.lock +0 -7
  30. package/tests/fixtures/package-json/minimal.json +0 -4
  31. package/tests/fixtures/package-json/scoped.json +0 -6
  32. package/tests/fixtures/package-json/valid.json +0 -13
  33. package/tests/integration/comment/basic.bats +0 -95
  34. package/tests/integration/npm-pr-version/basic.bats +0 -438
  35. package/tests/integration/setup-node-and-install/basic.bats +0 -638
  36. package/tests/scripts/test-helpers.sh +0 -113
  37. package/tests/scripts/test-runner.sh +0 -115
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  A collection of reusable GitHub Actions for common development workflows. Each action is self-contained and designed for
4
4
  maximum reusability across different projects.
5
5
 
6
- <!-- prettier-ignore-start -->
6
+ <!-- eslint-disable -->
7
7
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
8
8
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9
9
  ## Table of Contents
@@ -15,20 +15,22 @@ maximum reusability across different projects.
15
15
  - [setup-node-and-install](#setup-node-and-install)
16
16
  - [Contributing](#contributing)
17
17
  - [Example Workflow](#example-workflow)
18
+ - [Maintenance](#maintenance)
19
+ - [Test pull requests in downstream apps before merging](#test-pull-requests-in-downstream-apps-before-merging)
18
20
 
19
21
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
20
- <!-- prettier-ignore-end -->
22
+ <!-- eslint-enable -->
21
23
 
22
24
  ## Usage
23
25
 
24
26
  Reference actions using the following format:
25
27
 
26
- ```yaml
28
+ ```yml
27
29
  uses: codfish/actions/{action-name}@main
28
- uses: codfish/actions/{action-name}@v2
29
- uses: codfish/actions/{action-name}@v2.0.1
30
+ uses: codfish/actions/{action-name}@v3
31
+ uses: codfish/actions/{action-name}@v3.0.1
30
32
  uses: codfish/actions/{action-name}@feature-branch
31
- uses: codfish/actions/{action-name}@aff1a9d
33
+ uses: codfish/actions/{action-name}@9f7cf1a3ff9f2838eff5ec9ac69b6ff277610bb2
32
34
  ```
33
35
 
34
36
  ## Available Actions
@@ -49,9 +51,9 @@ Creates or updates a comment in a pull request with optional tagging for upsert
49
51
 
50
52
  **Usage:**
51
53
 
52
- ```yaml
54
+ ```yml
53
55
  - name: Comment on PR
54
- uses: codfish/actions/comment@v2
56
+ uses: codfish/actions/comment@v3
55
57
  with:
56
58
  message: '✅ Build successful!'
57
59
  tag: 'build-status'
@@ -60,17 +62,18 @@ Creates or updates a comment in a pull request with optional tagging for upsert
60
62
 
61
63
  ### [npm-pr-version](./npm-publish-pr/)
62
64
 
63
- Publishes package with PR-specific version (0.0.0-PR-123--abc1234) using detected package manager (npm/yarn/pnpm) and
64
- automatically comments on PR
65
+ Publishes package with PR-specific version (0.0.0-PR-123--abc1234) using detected package manager (npm/yarn/pnpm) or
66
+ OIDC trusted publishing, and automatically comments on PR
65
67
 
66
68
  **Inputs:**
67
69
 
68
- | Input | Description | Required | Default |
69
- | -------------- | ----------------------------------------------------------------------------------- | -------- | ---------------- |
70
- | `npm-token` | Registry authentication token with publish permissions (works with npm/yarn/pnpm) | Yes | - |
71
- | `github-token` | GitHub token with pull request comment permissions (typically secrets.GITHUB_TOKEN) | Yes | - |
72
- | `comment` | Whether to comment on the PR with the published version (true/false) | No | `true` |
73
- | `comment-tag` | Tag to use for PR comments (for comment identification and updates) | No | `npm-publish-pr` |
70
+ | Input | Description | Required | Default |
71
+ | ------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ---------------- |
72
+ | `npm-token` | Registry authentication token with publish permissions. If not provided, OIDC trusted publishing will be used. | No | - |
73
+ | `tarball` | Path to pre-built tarball to publish (e.g., '\*.tgz'). When provided, publishes the tarball with --ignore-scripts for security. Recommended for pull_request_target workflows to prevent execution of malicious lifecycle scripts. | No | - |
74
+ | `comment` | Whether to comment on the PR with the published version (true/false) | No | `true` |
75
+ | `comment-tag` | Tag to use for PR comments (for comment identification and updates) | No | `npm-publish-pr` |
76
+ | `dev` | If true, use dev dependency install syntax in the PR comment (e.g. npm install -D, pnpm add -D). | No | `false` |
74
77
 
75
78
  **Outputs:**
76
79
 
@@ -82,20 +85,25 @@ automatically comments on PR
82
85
 
83
86
  **Usage:**
84
87
 
85
- ```yaml
86
- steps:
87
- - uses: actions/checkout@v5
88
+ ```yml
89
+ on: pull_request
88
90
 
89
- - uses: codfish/actions/setup-node-and-install@v2
90
- with:
91
- node-version: lts/*
91
+ jobs:
92
+ publish:
93
+ permissions:
94
+ id-token: write
95
+ pull-requests: write
92
96
 
93
- - run: npm run build
97
+ steps:
98
+ - uses: actions/checkout@v6
94
99
 
95
- - uses: codfish/actions/npm-pr-version@v2
96
- with:
97
- npm-token: ${{ secrets.NPM_TOKEN }}
98
- github-token: ${{ secrets.GITHUB_TOKEN }}
100
+ - uses: codfish/actions/setup-node-and-install@v3
101
+ with:
102
+ node-version: lts/*
103
+
104
+ - run: npm run build
105
+
106
+ - uses: codfish/actions/npm-pr-version@v3
99
107
  ```
100
108
 
101
109
  ### [setup-node-and-install](./setup-node-and-install/)
@@ -105,29 +113,36 @@ intelligent caching, and version detection via input, .node-version, .nvmrc, or
105
113
 
106
114
  **Inputs:**
107
115
 
108
- | Input | Description | Required | Default |
109
- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
110
- | `node-version` | Node.js version to install (e.g. "24", "lts/\*"). Precedence: node-version input > .node-version > .nvmrc > package.json volta.node. | No | - |
111
- | `install-options` | Extra command-line options to pass to npm/pnpm/yarn install. | No | - |
112
- | `working-directory` | Directory containing package.json and lockfile. | No | `.` |
116
+ | Input | Description | Required | Default |
117
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
118
+ | `node-version` | Node.js version to install (e.g. "24", "lts/\*"). Precedence: node-version input > .node-version > .nvmrc > package.json volta.node. | No | - |
119
+ | `install-options` | Extra command-line options to pass to npm/pnpm/yarn install. | No | - |
120
+ | `working-directory` | Directory containing package.json and lockfile. | No | `.` |
121
+ | `registry-url` | Optional registry URL to configure for publishing (e.g. "https://registry.npmjs.org/"). Creates .npmrc with NODE_AUTH_TOKEN placeholder. NOT recommended if using semantic-release (it handles auth independently). Only needed for publishing with manual npm publish or other non-semantic-release workflows. | No | - |
122
+ | `upgrade-npm` | Whether to upgrade npm to v11.5.1. This is required for OIDC trusted publishing but can be disabled if you want to shave off some run time and you are still using token-based authentication. | No | `true` |
113
123
 
114
124
  **Outputs:**
115
125
 
116
- | Output | Description |
117
- | ----------- | -------------------------------------------------- |
118
- | `cache-hit` | Whether the dependency cache was hit (true/false). |
126
+ | Output | Description |
127
+ | --------------- | -------------------------------------------------- |
128
+ | `node-version` | The installed node version. |
129
+ | `cache-hit` | Whether the dependency cache was hit (true/false). |
130
+ | `pnpm-dest` | Expanded path of pnpm dest. |
131
+ | `pnpm-bin-dest` | Location of pnpm and pnpx command. |
119
132
 
120
133
  **Usage:**
121
134
 
122
- ```yaml
135
+ ```yml
123
136
  steps:
124
- - uses: actions/checkout@v5
137
+ - uses: actions/checkout@v6
138
+
139
+ # Will setup node, inferring node version from your codebase & installing your dependencies
140
+ - uses: codfish/actions/setup-node-and-install@v3
125
141
 
126
- # will install latest Node v18.x
127
- - uses: codfish/actions/setup-node-and-install@v2
142
+ # Or if you want to be explicit
143
+ - uses: codfish/actions/setup-node-and-install@v3
128
144
  with:
129
- node-version: 18
130
- cache-key-suffix: '-${{ github.head_ref || github.event.release.tag_name }}'
145
+ node-version: 24.4
131
146
 
132
147
  - run: npm test
133
148
  ```
@@ -145,53 +160,55 @@ Each action follows these conventions:
145
160
 
146
161
  ## Example Workflow
147
162
 
148
- Complete workflow using multiple actions together:
163
+ Complete workflow using multiple actions together with secure OIDC trusted publishing:
149
164
 
150
- ```yaml
151
- name: CI/CD Pipeline
152
- on:
153
- pull_request:
154
- types: [opened, synchronize]
165
+ ```yml
166
+ name: Validate
167
+
168
+ on: pull_request_target
155
169
 
156
170
  jobs:
157
- test-and-publish:
171
+ # Build and test with untrusted PR code (no secrets)
172
+ build-and-test:
158
173
  runs-on: ubuntu-latest
159
- steps:
160
- - uses: actions/checkout@v5
161
174
 
162
- - uses: codfish/actions/setup-node-and-install@v2
175
+ permissions:
176
+ contents: read
177
+ pull-requests: write
178
+
179
+ steps:
180
+ - uses: actions/checkout@v6
163
181
  with:
164
- node-version: 'lts/*'
182
+ ref: ${{ github.event.pull_request.head.sha }}
183
+
184
+ - uses: codfish/actions/setup-node-and-install@v3
165
185
 
166
186
  - name: Run tests
187
+ id: test
167
188
  run: |
168
- npm test 2>&1 | tee test-output.txt
189
+ pnpm test 2>&1 | tee test-output.txt
169
190
  if grep -q "All tests passed" test-output.txt; then
170
191
  echo "status=✅ passed" >> $GITHUB_OUTPUT
171
192
  else
172
193
  echo "status=❌ failed" >> $GITHUB_OUTPUT
173
194
  fi
174
195
  echo "count=$(grep -c "✓\|√\|PASS" test-output.txt || echo "unknown")" >> $GITHUB_OUTPUT
175
- id: test
176
196
 
177
197
  - name: Build package
178
- run: npm run build
179
-
180
- - name: Calculate build size
198
+ id: build
181
199
  run: |
200
+ pnpm build
201
+
182
202
  if [ -d "dist" ]; then
183
203
  size=$(du -sh dist | cut -f1)
184
204
  elif [ -d "build" ]; then
185
205
  size=$(du -sh build | cut -f1)
186
- elif [ -f "package.json" ]; then
187
- size=$(du -sh . --exclude=node_modules | cut -f1)
188
206
  else
189
207
  size="unknown"
190
208
  fi
191
209
  echo "size=$size" >> $GITHUB_OUTPUT
192
- id: build
193
210
 
194
- - uses: codfish/actions/comment@v2
211
+ - uses: codfish/actions/comment@v3
195
212
  with:
196
213
  message: |
197
214
  ## 🚀 **Build Summary**
@@ -204,9 +221,64 @@ jobs:
204
221
  tag: 'build-summary'
205
222
  upsert: true
206
223
 
207
- - uses: codfish/actions/npm-pr-version@v2
224
+ - name: Create package tarball
225
+ run: pnpm pack
226
+
227
+ - uses: actions/upload-artifact@v4
208
228
  with:
209
- npm-token: ${{ secrets.NPM_TOKEN }}
210
- github-token: ${{ secrets.GITHUB_TOKEN }}
229
+ name: package-tarball
230
+ path: '*.tgz'
231
+ retention-days: 1
232
+
233
+ # Publish with secrets using only trusted base branch code
234
+ publish:
235
+ needs: build-and-test
236
+
237
+ runs-on: ubuntu-latest
238
+
239
+ permissions:
240
+ contents: read
241
+ id-token: write
242
+ pull-requests: write
243
+
244
+ steps:
245
+ - uses: actions/checkout@v6
246
+ # No ref = uses base branch (trusted code only)
247
+
248
+ - uses: codfish/actions/setup-node-and-install@v3
249
+
250
+ - uses: actions/download-artifact@v4
251
+ with:
252
+ name: package-tarball
253
+
254
+ - uses: codfish/actions/npm-pr-version@v3
255
+ with:
256
+ tarball: '*.tgz' # Secure: uses --ignore-scripts
211
257
  comment-tag: 'pr-package'
212
258
  ```
259
+
260
+ ## Maintenance
261
+
262
+ > The release workflow automatically updates the major version tag (v3, v4, v5, etc.) to point to the latest release for
263
+ > that major version. This allows users binding to the major version tag to automatically receive the most recent stable
264
+ > minor/patch releases.
265
+
266
+ This happens automatically in the [release workflow](.github/workflows/release.yml) after each successful release.
267
+
268
+ If you need to update the major version tag manually:
269
+
270
+ ```sh
271
+ git tag -fa v5 -m "Update v5 tag" && git push origin v5 --force
272
+ ```
273
+
274
+ **Reference**: https://github.com/actions/toolkit/blob/main/docs/action-versioning.md#recommendations
275
+
276
+ ### Test pull requests in downstream apps before merging
277
+
278
+ Our validation workflow builds and publishes a multi-arch Docker image to GitHub Container Registry for every pull
279
+ request, tagging the image with the PR's branch name. You can point downstream repositories at this branch-tagged image
280
+ to try changes before merging.
281
+
282
+ ```yml
283
+ - uses: codfish/actions:<branch-name>
284
+ ```
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import fs from 'fs';
4
- import yaml from 'js-yaml';
4
+ import yml from 'js-yaml';
5
5
  import path from 'path';
6
6
 
7
7
  /**
@@ -37,7 +37,7 @@ class DocumentationGenerator {
37
37
 
38
38
  try {
39
39
  const content = fs.readFileSync(actionFile, 'utf8');
40
- const actionData = yaml.load(content);
40
+ const actionData = yml.load(content);
41
41
 
42
42
  return {
43
43
  directory: dirName,
@@ -68,12 +68,12 @@ class DocumentationGenerator {
68
68
 
69
69
  // Look for usage examples in various sections
70
70
  const patterns = [
71
- // Look for "## Usage" section with yaml code block
72
- /## Usage[\s\S]*?```yaml\n([\s\S]*?)\n```/i,
73
- // Look for any yaml code block with "uses: "
74
- /```yaml\n([\s\S]*?uses:\s*[.\w/-]+[\s\S]*?)\n```/i,
71
+ // Look for "## Usage" section with yml code block
72
+ /## Usage[\s\S]*?```yml\n([\s\S]*?)\n```/i,
73
+ // Look for any yml code block with "uses: "
74
+ /```yml\n([\s\S]*?uses:\s*[.\w/-]+[\s\S]*?)\n```/i,
75
75
  // Look for specific action usage
76
- new RegExp(`\`\`\`yaml\\n([\\s\\S]*?uses:\\s*[^\\n]*${dirName}[\\s\\S]*?)\\n\`\`\``, 'i'),
76
+ new RegExp(`\`\`\`yml\\n([\\s\\S]*?uses:\\s*[^\\n]*${dirName}[\\s\\S]*?)\\n\`\`\``, 'i'),
77
77
  ];
78
78
 
79
79
  for (const pattern of patterns) {
@@ -84,7 +84,7 @@ class DocumentationGenerator {
84
84
 
85
85
  // If it doesn't start with a step name, add one
86
86
  if (!example.match(/^\s*-\s*name:/m) && !example.match(/^\s*-\s*uses:/m)) {
87
- return `- uses: codfish/actions/${dirName}@v2\n${example.replace(/^/gm, ' ')}`;
87
+ return `- uses: codfish/actions/${dirName}@v3\n${example.replace(/^/gm, ' ')}`;
88
88
  }
89
89
 
90
90
  return example;
@@ -103,7 +103,7 @@ class DocumentationGenerator {
103
103
  * Generate a basic usage example based on action inputs
104
104
  */
105
105
  generateBasicExample(dirName, inputs = {}) {
106
- let example = `- uses: codfish/actions/${dirName}@v2`;
106
+ let example = `- uses: codfish/actions/${dirName}@v3`;
107
107
 
108
108
  const inputKeys = Object.keys(inputs);
109
109
  if (inputKeys.length > 0) {
@@ -180,7 +180,7 @@ class DocumentationGenerator {
180
180
 
181
181
  // Add usage example
182
182
  if (usageExample) {
183
- section += `**Usage:**\n\n\`\`\`yaml\n${usageExample}\n\`\`\`\n\n`;
183
+ section += `**Usage:**\n\n\`\`\`yml\n${usageExample}\n\`\`\`\n\n`;
184
184
  }
185
185
 
186
186
  return section;
package/comment/README.md CHANGED
@@ -8,9 +8,9 @@ Creates or updates pull request comments with intelligent upsert functionality u
8
8
 
9
9
  See [action.yml](action.yml).
10
10
 
11
- ```yaml
11
+ ```yml
12
12
  - name: Comment on PR
13
- uses: codfish/actions/comment@v2
13
+ uses: codfish/actions/comment@v3
14
14
  with:
15
15
  message: '✅ Build successful!'
16
16
  tag: 'build-status'
@@ -33,8 +33,8 @@ See [action.yml](action.yml).
33
33
 
34
34
  ### Basic comment
35
35
 
36
- ```yaml
37
- - uses: codfish/actions/comment@v2
36
+ ```yml
37
+ - uses: codfish/actions/comment@v3
38
38
  with:
39
39
  message: 'Hello from GitHub Actions! 👋'
40
40
  ```
@@ -43,9 +43,9 @@ See [action.yml](action.yml).
43
43
 
44
44
  Use the `upsert` feature to update the same comment instead of creating multiple comments:
45
45
 
46
- ```yaml
46
+ ```yml
47
47
  - name: Update build status
48
- uses: codfish/actions/comment@v2
48
+ uses: codfish/actions/comment@v3
49
49
  with:
50
50
  message: |
51
51
  ## Build Status
@@ -55,7 +55,7 @@ Use the `upsert` feature to update the same comment instead of creating multiple
55
55
 
56
56
  # Later in the workflow...
57
57
  - name: Update build status
58
- uses: codfish/actions/comment@v2
58
+ uses: codfish/actions/comment@v3
59
59
  with:
60
60
  message: |
61
61
  ## Build Status
@@ -66,8 +66,8 @@ Use the `upsert` feature to update the same comment instead of creating multiple
66
66
 
67
67
  ### Multi-line markdown comment
68
68
 
69
- ```yaml
70
- - uses: codfish/actions/comment@v2
69
+ ```yml
70
+ - uses: codfish/actions/comment@v3
71
71
  with:
72
72
  message: |
73
73
  ## 📊 Test Results
@@ -46,7 +46,7 @@ runs:
46
46
  - name: Check existing comments
47
47
  id: check-comments
48
48
  if: inputs.upsert == 'true'
49
- uses: actions/github-script@v7
49
+ uses: actions/github-script@v8
50
50
  with:
51
51
  script: |
52
52
  try {
@@ -69,7 +69,7 @@ runs:
69
69
 
70
70
  - name: Update existing comment
71
71
  if: steps.check-comments.outputs.comment-id != null
72
- uses: actions/github-script@v7
72
+ uses: actions/github-script@v8
73
73
  with:
74
74
  script: |
75
75
  try {
@@ -86,7 +86,7 @@ runs:
86
86
 
87
87
  - name: Create new comment
88
88
  if: steps.check-comments.outputs.comment-id == null
89
- uses: actions/github-script@v7
89
+ uses: actions/github-script@v8
90
90
  with:
91
91
  script: |
92
92
  try {