@codfish/actions 2.0.0 → 3.3.1

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 +135 -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 +319 -40
  6. package/npm-publish-pr/action.yml +271 -87
  7. package/package.json +19 -14
  8. package/setup-node-and-install/README.md +77 -34
  9. package/setup-node-and-install/action.yml +40 -5
  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}@v1
29
- uses: codfish/actions/{action-name}@v1.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@v1
56
+ uses: codfish/actions/comment@v3
55
57
  with:
56
58
  message: '✅ Build successful!'
57
59
  tag: 'build-status'
@@ -60,17 +62,17 @@ 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` |
74
76
 
75
77
  **Outputs:**
76
78
 
@@ -82,20 +84,25 @@ automatically comments on PR
82
84
 
83
85
  **Usage:**
84
86
 
85
- ```yaml
86
- steps:
87
- - uses: actions/checkout@v5
87
+ ```yml
88
+ on: pull_request
88
89
 
89
- - uses: codfish/actions/setup-node-and-install@v1
90
- with:
91
- node-version: lts/*
90
+ jobs:
91
+ publish:
92
+ permissions:
93
+ id-token: write
94
+ pull-requests: write
92
95
 
93
- - run: npm run build
96
+ steps:
97
+ - uses: actions/checkout@v6
94
98
 
95
- - uses: codfish/actions/npm-pr-version@v1
96
- with:
97
- npm-token: ${{ secrets.NPM_TOKEN }}
98
- github-token: ${{ secrets.GITHUB_TOKEN }}
99
+ - uses: codfish/actions/setup-node-and-install@v3
100
+ with:
101
+ node-version: lts/*
102
+
103
+ - run: npm run build
104
+
105
+ - uses: codfish/actions/npm-pr-version@v3
99
106
  ```
100
107
 
101
108
  ### [setup-node-and-install](./setup-node-and-install/)
@@ -105,29 +112,36 @@ intelligent caching, and version detection via input, .node-version, .nvmrc, or
105
112
 
106
113
  **Inputs:**
107
114
 
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 | `.` |
115
+ | Input | Description | Required | Default |
116
+ | ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------- |
117
+ | `node-version` | Node.js version to install (e.g. "24", "lts/\*"). Precedence: node-version input > .node-version > .nvmrc > package.json volta.node. | No | - |
118
+ | `install-options` | Extra command-line options to pass to npm/pnpm/yarn install. | No | - |
119
+ | `working-directory` | Directory containing package.json and lockfile. | No | `.` |
120
+ | `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 | - |
121
+ | `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
122
 
114
123
  **Outputs:**
115
124
 
116
- | Output | Description |
117
- | ----------- | -------------------------------------------------- |
118
- | `cache-hit` | Whether the dependency cache was hit (true/false). |
125
+ | Output | Description |
126
+ | --------------- | -------------------------------------------------- |
127
+ | `node-version` | The installed node version. |
128
+ | `cache-hit` | Whether the dependency cache was hit (true/false). |
129
+ | `pnpm-dest` | Expanded path of pnpm dest. |
130
+ | `pnpm-bin-dest` | Location of pnpm and pnpx command. |
119
131
 
120
132
  **Usage:**
121
133
 
122
- ```yaml
134
+ ```yml
123
135
  steps:
124
- - uses: actions/checkout@v5
136
+ - uses: actions/checkout@v6
137
+
138
+ # Will setup node, inferring node version from your codebase & installing your dependencies
139
+ - uses: codfish/actions/setup-node-and-install@v3
125
140
 
126
- # will install latest Node v18.x
127
- - uses: codfish/actions/setup-node-and-install@v1
141
+ # Or if you want to be explicit
142
+ - uses: codfish/actions/setup-node-and-install@v3
128
143
  with:
129
- node-version: 18
130
- cache-key-suffix: '-${{ github.head_ref || github.event.release.tag_name }}'
144
+ node-version: 24.4
131
145
 
132
146
  - run: npm test
133
147
  ```
@@ -145,53 +159,55 @@ Each action follows these conventions:
145
159
 
146
160
  ## Example Workflow
147
161
 
148
- Complete workflow using multiple actions together:
162
+ Complete workflow using multiple actions together with secure OIDC trusted publishing:
149
163
 
150
- ```yaml
151
- name: CI/CD Pipeline
152
- on:
153
- pull_request:
154
- types: [opened, synchronize]
164
+ ```yml
165
+ name: Validate
166
+
167
+ on: pull_request_target
155
168
 
156
169
  jobs:
157
- test-and-publish:
170
+ # Build and test with untrusted PR code (no secrets)
171
+ build-and-test:
158
172
  runs-on: ubuntu-latest
159
- steps:
160
- - uses: actions/checkout@v5
161
173
 
162
- - uses: codfish/actions/setup-node-and-install@v1
174
+ permissions:
175
+ contents: read
176
+ pull-requests: write
177
+
178
+ steps:
179
+ - uses: actions/checkout@v6
163
180
  with:
164
- node-version: 'lts/*'
181
+ ref: ${{ github.event.pull_request.head.sha }}
182
+
183
+ - uses: codfish/actions/setup-node-and-install@v3
165
184
 
166
185
  - name: Run tests
186
+ id: test
167
187
  run: |
168
- npm test 2>&1 | tee test-output.txt
188
+ pnpm test 2>&1 | tee test-output.txt
169
189
  if grep -q "All tests passed" test-output.txt; then
170
190
  echo "status=✅ passed" >> $GITHUB_OUTPUT
171
191
  else
172
192
  echo "status=❌ failed" >> $GITHUB_OUTPUT
173
193
  fi
174
194
  echo "count=$(grep -c "✓\|√\|PASS" test-output.txt || echo "unknown")" >> $GITHUB_OUTPUT
175
- id: test
176
195
 
177
196
  - name: Build package
178
- run: npm run build
179
-
180
- - name: Calculate build size
197
+ id: build
181
198
  run: |
199
+ pnpm build
200
+
182
201
  if [ -d "dist" ]; then
183
202
  size=$(du -sh dist | cut -f1)
184
203
  elif [ -d "build" ]; then
185
204
  size=$(du -sh build | cut -f1)
186
- elif [ -f "package.json" ]; then
187
- size=$(du -sh . --exclude=node_modules | cut -f1)
188
205
  else
189
206
  size="unknown"
190
207
  fi
191
208
  echo "size=$size" >> $GITHUB_OUTPUT
192
- id: build
193
209
 
194
- - uses: codfish/actions/comment@v1
210
+ - uses: codfish/actions/comment@v3
195
211
  with:
196
212
  message: |
197
213
  ## 🚀 **Build Summary**
@@ -204,9 +220,64 @@ jobs:
204
220
  tag: 'build-summary'
205
221
  upsert: true
206
222
 
207
- - uses: codfish/actions/npm-pr-version@v1
223
+ - name: Create package tarball
224
+ run: pnpm pack
225
+
226
+ - uses: actions/upload-artifact@v4
208
227
  with:
209
- npm-token: ${{ secrets.NPM_TOKEN }}
210
- github-token: ${{ secrets.GITHUB_TOKEN }}
228
+ name: package-tarball
229
+ path: '*.tgz'
230
+ retention-days: 1
231
+
232
+ # Publish with secrets using only trusted base branch code
233
+ publish:
234
+ needs: build-and-test
235
+
236
+ runs-on: ubuntu-latest
237
+
238
+ permissions:
239
+ contents: read
240
+ id-token: write
241
+ pull-requests: write
242
+
243
+ steps:
244
+ - uses: actions/checkout@v6
245
+ # No ref = uses base branch (trusted code only)
246
+
247
+ - uses: codfish/actions/setup-node-and-install@v3
248
+
249
+ - uses: actions/download-artifact@v4
250
+ with:
251
+ name: package-tarball
252
+
253
+ - uses: codfish/actions/npm-pr-version@v3
254
+ with:
255
+ tarball: '*.tgz' # Secure: uses --ignore-scripts
211
256
  comment-tag: 'pr-package'
212
257
  ```
258
+
259
+ ## Maintenance
260
+
261
+ > The release workflow automatically updates the major version tag (v3, v4, v5, etc.) to point to the latest release for
262
+ > that major version. This allows users binding to the major version tag to automatically receive the most recent stable
263
+ > minor/patch releases.
264
+
265
+ This happens automatically in the [release workflow](.github/workflows/release.yml) after each successful release.
266
+
267
+ If you need to update the major version tag manually:
268
+
269
+ ```sh
270
+ git tag -fa v5 -m "Update v5 tag" && git push origin v5 --force
271
+ ```
272
+
273
+ **Reference**: https://github.com/actions/toolkit/blob/main/docs/action-versioning.md#recommendations
274
+
275
+ ### Test pull requests in downstream apps before merging
276
+
277
+ Our validation workflow builds and publishes a multi-arch Docker image to GitHub Container Registry for every pull
278
+ request, tagging the image with the PR's branch name. You can point downstream repositories at this branch-tagged image
279
+ to try changes before merging.
280
+
281
+ ```yml
282
+ - uses: codfish/actions:<branch-name>
283
+ ```
@@ -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}@v1\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}@v1`;
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@v1
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@v1
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@v1
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@v1
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@v1
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 {