@codfish/actions 1.1.0 → 2.0.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.
- package/.github/workflows/claude.yml +0 -1
- package/AGENT.md +21 -1
- package/README.md +22 -17
- package/SECURITY.md +2 -2
- package/bin/generate-docs.js +2 -2
- package/comment/README.md +5 -5
- package/npm-publish-pr/README.md +8 -8
- package/npm-publish-pr/action.yml +22 -15
- package/package.json +1 -1
- package/setup-node-and-install/README.md +23 -21
- package/setup-node-and-install/action.yml +98 -123
- package/tests/integration/comment/basic.bats +11 -11
- package/tests/integration/npm-pr-version/basic.bats +131 -46
- package/tests/integration/setup-node-and-install/basic.bats +471 -33
package/AGENT.md
CHANGED
|
@@ -62,7 +62,8 @@ This project uses **pnpm** as the package manager. All commands should use pnpm:
|
|
|
62
62
|
- `comment` - Creates or updates pull request comments with intelligent upsert functionality using unique tags
|
|
63
63
|
- **IMPORTANT**: Any job using the comment action must include `permissions: pull-requests: write`
|
|
64
64
|
- `setup-node-and-install` - Sets up Node.js environment and installs dependencies with automatic package manager
|
|
65
|
-
detection, intelligent caching, and
|
|
65
|
+
detection, intelligent caching, and dynamic Node version detection via input, `.node-version`, `.nvmrc`, or
|
|
66
|
+
`package.json` `volta.node`. Validation is relaxed; the action no longer fails when no version is detected.
|
|
66
67
|
|
|
67
68
|
## Testing
|
|
68
69
|
|
|
@@ -127,3 +128,22 @@ The project implements multiple security measures:
|
|
|
127
128
|
- **Vulnerability auditing**: Regular pnpm audit checks
|
|
128
129
|
- **Note**: Dependency review requires GitHub Advanced Security (available free on public repos, paid feature for
|
|
129
130
|
private repos)
|
|
131
|
+
|
|
132
|
+
## Code Quality and File Editing Rules
|
|
133
|
+
|
|
134
|
+
### Bats File Editing Rules
|
|
135
|
+
|
|
136
|
+
**CRITICAL**: After editing any `.bats` file, ALWAYS check for and remove trailing spaces:
|
|
137
|
+
|
|
138
|
+
1. Run: `grep -n " $" path/to/file.bats`
|
|
139
|
+
2. If any trailing spaces are found, remove them immediately
|
|
140
|
+
3. Bats files are NOT automatically formatted by eslint/prettier, so manual cleanup is required
|
|
141
|
+
4. Trailing spaces in bats files can cause test execution issues
|
|
142
|
+
|
|
143
|
+
### General File Editing Guidelines
|
|
144
|
+
|
|
145
|
+
- Do what has been asked; nothing more, nothing less
|
|
146
|
+
- NEVER create files unless they're absolutely necessary for achieving your goal
|
|
147
|
+
- ALWAYS prefer editing an existing file to creating a new one
|
|
148
|
+
- NEVER proactively create documentation files (\*.md) or README files. Only create documentation files if explicitly
|
|
149
|
+
requested by the User
|
package/README.md
CHANGED
|
@@ -25,8 +25,8 @@ Reference actions using the following format:
|
|
|
25
25
|
|
|
26
26
|
```yaml
|
|
27
27
|
uses: codfish/actions/{action-name}@main
|
|
28
|
-
uses: codfish/actions/{action-name}@
|
|
29
|
-
uses: codfish/actions/{action-name}@
|
|
28
|
+
uses: codfish/actions/{action-name}@v2
|
|
29
|
+
uses: codfish/actions/{action-name}@v2.0.1
|
|
30
30
|
uses: codfish/actions/{action-name}@feature-branch
|
|
31
31
|
uses: codfish/actions/{action-name}@aff1a9d
|
|
32
32
|
```
|
|
@@ -51,7 +51,7 @@ Creates or updates a comment in a pull request with optional tagging for upsert
|
|
|
51
51
|
|
|
52
52
|
```yaml
|
|
53
53
|
- name: Comment on PR
|
|
54
|
-
uses: codfish/actions/comment@
|
|
54
|
+
uses: codfish/actions/comment@v2
|
|
55
55
|
with:
|
|
56
56
|
message: '✅ Build successful!'
|
|
57
57
|
tag: 'build-status'
|
|
@@ -67,7 +67,7 @@ automatically comments on PR
|
|
|
67
67
|
|
|
68
68
|
| Input | Description | Required | Default |
|
|
69
69
|
| -------------- | ----------------------------------------------------------------------------------- | -------- | ---------------- |
|
|
70
|
-
| `npm-token` | Registry authentication token with publish permissions (works with npm/yarn/pnpm) |
|
|
70
|
+
| `npm-token` | Registry authentication token with publish permissions (works with npm/yarn/pnpm) | Yes | - |
|
|
71
71
|
| `github-token` | GitHub token with pull request comment permissions (typically secrets.GITHUB_TOKEN) | Yes | - |
|
|
72
72
|
| `comment` | Whether to comment on the PR with the published version (true/false) | No | `true` |
|
|
73
73
|
| `comment-tag` | Tag to use for PR comments (for comment identification and updates) | No | `npm-publish-pr` |
|
|
@@ -86,13 +86,13 @@ automatically comments on PR
|
|
|
86
86
|
steps:
|
|
87
87
|
- uses: actions/checkout@v5
|
|
88
88
|
|
|
89
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
89
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
90
90
|
with:
|
|
91
91
|
node-version: lts/*
|
|
92
92
|
|
|
93
93
|
- run: npm run build
|
|
94
94
|
|
|
95
|
-
- uses: codfish/actions/npm-pr-version@
|
|
95
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
96
96
|
with:
|
|
97
97
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
98
98
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -101,16 +101,21 @@ steps:
|
|
|
101
101
|
### [setup-node-and-install](./setup-node-and-install/)
|
|
102
102
|
|
|
103
103
|
Sets up Node.js environment and installs dependencies with automatic package manager detection (npm/pnpm/yarn),
|
|
104
|
-
intelligent caching, and .
|
|
104
|
+
intelligent caching, and version detection via input, .node-version, .nvmrc, or package.json volta.node
|
|
105
105
|
|
|
106
106
|
**Inputs:**
|
|
107
107
|
|
|
108
|
-
| Input | Description
|
|
109
|
-
| ------------------- |
|
|
110
|
-
| `node-version` | Node.js version to install (e.g.
|
|
111
|
-
| `
|
|
112
|
-
| `
|
|
113
|
-
|
|
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 | `.` |
|
|
113
|
+
|
|
114
|
+
**Outputs:**
|
|
115
|
+
|
|
116
|
+
| Output | Description |
|
|
117
|
+
| ----------- | -------------------------------------------------- |
|
|
118
|
+
| `cache-hit` | Whether the dependency cache was hit (true/false). |
|
|
114
119
|
|
|
115
120
|
**Usage:**
|
|
116
121
|
|
|
@@ -119,7 +124,7 @@ steps:
|
|
|
119
124
|
- uses: actions/checkout@v5
|
|
120
125
|
|
|
121
126
|
# will install latest Node v18.x
|
|
122
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
127
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
123
128
|
with:
|
|
124
129
|
node-version: 18
|
|
125
130
|
cache-key-suffix: '-${{ github.head_ref || github.event.release.tag_name }}'
|
|
@@ -154,7 +159,7 @@ jobs:
|
|
|
154
159
|
steps:
|
|
155
160
|
- uses: actions/checkout@v5
|
|
156
161
|
|
|
157
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
162
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
158
163
|
with:
|
|
159
164
|
node-version: 'lts/*'
|
|
160
165
|
|
|
@@ -186,7 +191,7 @@ jobs:
|
|
|
186
191
|
echo "size=$size" >> $GITHUB_OUTPUT
|
|
187
192
|
id: build
|
|
188
193
|
|
|
189
|
-
- uses: codfish/actions/comment@
|
|
194
|
+
- uses: codfish/actions/comment@v2
|
|
190
195
|
with:
|
|
191
196
|
message: |
|
|
192
197
|
## 🚀 **Build Summary**
|
|
@@ -199,7 +204,7 @@ jobs:
|
|
|
199
204
|
tag: 'build-summary'
|
|
200
205
|
upsert: true
|
|
201
206
|
|
|
202
|
-
- uses: codfish/actions/npm-pr-version@
|
|
207
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
203
208
|
with:
|
|
204
209
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
205
210
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
package/SECURITY.md
CHANGED
|
@@ -90,7 +90,7 @@ When using these GitHub Actions in your workflows:
|
|
|
90
90
|
|
|
91
91
|
```yaml
|
|
92
92
|
# ✅ Good - Using secrets properly
|
|
93
|
-
- uses: codfish/actions/npm-pr-version@
|
|
93
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
94
94
|
with:
|
|
95
95
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
96
96
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -107,7 +107,7 @@ When using these GitHub Actions in your workflows:
|
|
|
107
107
|
|
|
108
108
|
```yaml
|
|
109
109
|
# ✅ Good - Pinned version
|
|
110
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
110
|
+
- uses: codfish/actions/setup-node-and-install@v2.2.3
|
|
111
111
|
|
|
112
112
|
# ⚠️ Caution - Latest main (testing only)
|
|
113
113
|
- uses: codfish/actions/setup-node-and-install@main
|
package/bin/generate-docs.js
CHANGED
|
@@ -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}@
|
|
87
|
+
return `- uses: codfish/actions/${dirName}@v2\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}@
|
|
106
|
+
let example = `- uses: codfish/actions/${dirName}@v2`;
|
|
107
107
|
|
|
108
108
|
const inputKeys = Object.keys(inputs);
|
|
109
109
|
if (inputKeys.length > 0) {
|
package/comment/README.md
CHANGED
|
@@ -10,7 +10,7 @@ See [action.yml](action.yml).
|
|
|
10
10
|
|
|
11
11
|
```yaml
|
|
12
12
|
- name: Comment on PR
|
|
13
|
-
uses: codfish/actions/comment@
|
|
13
|
+
uses: codfish/actions/comment@v2
|
|
14
14
|
with:
|
|
15
15
|
message: '✅ Build successful!'
|
|
16
16
|
tag: 'build-status'
|
|
@@ -34,7 +34,7 @@ See [action.yml](action.yml).
|
|
|
34
34
|
### Basic comment
|
|
35
35
|
|
|
36
36
|
```yaml
|
|
37
|
-
- uses: codfish/actions/comment@
|
|
37
|
+
- uses: codfish/actions/comment@v2
|
|
38
38
|
with:
|
|
39
39
|
message: 'Hello from GitHub Actions! 👋'
|
|
40
40
|
```
|
|
@@ -45,7 +45,7 @@ Use the `upsert` feature to update the same comment instead of creating multiple
|
|
|
45
45
|
|
|
46
46
|
```yaml
|
|
47
47
|
- name: Update build status
|
|
48
|
-
uses: codfish/actions/comment@
|
|
48
|
+
uses: codfish/actions/comment@v2
|
|
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@
|
|
58
|
+
uses: codfish/actions/comment@v2
|
|
59
59
|
with:
|
|
60
60
|
message: |
|
|
61
61
|
## Build Status
|
|
@@ -67,7 +67,7 @@ Use the `upsert` feature to update the same comment instead of creating multiple
|
|
|
67
67
|
### Multi-line markdown comment
|
|
68
68
|
|
|
69
69
|
```yaml
|
|
70
|
-
- uses: codfish/actions/comment@
|
|
70
|
+
- uses: codfish/actions/comment@v2
|
|
71
71
|
with:
|
|
72
72
|
message: |
|
|
73
73
|
## 📊 Test Results
|
package/npm-publish-pr/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# npm-pr
|
|
1
|
+
# npm-publish-pr
|
|
2
2
|
|
|
3
3
|
Publishes packages with PR-specific version numbers for testing in downstream applications before merging. Automatically
|
|
4
4
|
detects your package manager (npm, yarn, or pnpm) and uses the appropriate publish command. The action generates
|
|
@@ -23,13 +23,13 @@ See [action.yml](action.yml).
|
|
|
23
23
|
steps:
|
|
24
24
|
- uses: actions/checkout@v5
|
|
25
25
|
|
|
26
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
26
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
27
27
|
with:
|
|
28
28
|
node-version: lts/*
|
|
29
29
|
|
|
30
30
|
- run: npm run build
|
|
31
31
|
|
|
32
|
-
- uses: codfish/actions/npm-pr-version@
|
|
32
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
33
33
|
with:
|
|
34
34
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
35
35
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -38,7 +38,7 @@ steps:
|
|
|
38
38
|
### Disable PR Comments
|
|
39
39
|
|
|
40
40
|
```yaml
|
|
41
|
-
- uses: codfish/actions/npm-pr-version@
|
|
41
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
42
42
|
with:
|
|
43
43
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
44
44
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -48,7 +48,7 @@ steps:
|
|
|
48
48
|
### Custom Comment Tag
|
|
49
49
|
|
|
50
50
|
```yaml
|
|
51
|
-
- uses: codfish/actions/npm-pr-version@
|
|
51
|
+
- uses: codfish/actions/npm-pr-version@v2
|
|
52
52
|
with:
|
|
53
53
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
54
54
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -72,7 +72,7 @@ jobs:
|
|
|
72
72
|
steps:
|
|
73
73
|
- uses: actions/checkout@v5
|
|
74
74
|
|
|
75
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
75
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
76
76
|
with:
|
|
77
77
|
node-version: 'lts/*'
|
|
78
78
|
|
|
@@ -80,7 +80,7 @@ jobs:
|
|
|
80
80
|
run: npm run build
|
|
81
81
|
|
|
82
82
|
- name: Publish PR package
|
|
83
|
-
uses: codfish/actions/npm-pr-version@
|
|
83
|
+
uses: codfish/actions/npm-pr-version@v2
|
|
84
84
|
with:
|
|
85
85
|
npm-token: ${{ secrets.NPM_TOKEN }}
|
|
86
86
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -102,7 +102,7 @@ The package is published under the `pr` tag, so it won't interfere with your reg
|
|
|
102
102
|
|
|
103
103
|
| Input | Description | Required | Default |
|
|
104
104
|
| -------------- | ----------------------------------------------------------------------------------- | -------- | ---------------- |
|
|
105
|
-
| `npm-token` | Registry authentication token with publish permissions (works with npm/yarn/pnpm) |
|
|
105
|
+
| `npm-token` | Registry authentication token with publish permissions (works with npm/yarn/pnpm) | Yes | - |
|
|
106
106
|
| `github-token` | GitHub token with pull request comment permissions (typically secrets.GITHUB_TOKEN) | Yes | - |
|
|
107
107
|
| `comment` | Whether to comment on the PR with the published version (true/false) | No | `true` |
|
|
108
108
|
| `comment-tag` | Tag to use for PR comments (for comment identification and updates) | No | `npm-publish-pr` |
|
|
@@ -6,7 +6,7 @@ description:
|
|
|
6
6
|
|
|
7
7
|
inputs:
|
|
8
8
|
npm-token:
|
|
9
|
-
required:
|
|
9
|
+
required: true
|
|
10
10
|
description: Registry authentication token with publish permissions (works with npm/yarn/pnpm)
|
|
11
11
|
github-token:
|
|
12
12
|
required: true
|
|
@@ -35,7 +35,7 @@ runs:
|
|
|
35
35
|
using: composite
|
|
36
36
|
|
|
37
37
|
steps:
|
|
38
|
-
- uses: codfish/actions/comment@
|
|
38
|
+
- uses: codfish/actions/comment@v2
|
|
39
39
|
if: inputs.comment == 'true'
|
|
40
40
|
with:
|
|
41
41
|
message: ⏳ Publishing PR version...
|
|
@@ -53,11 +53,18 @@ runs:
|
|
|
53
53
|
package_name=""
|
|
54
54
|
version=""
|
|
55
55
|
|
|
56
|
+
# Function to sanitize error messages for GitHub output
|
|
57
|
+
sanitize_error() {
|
|
58
|
+
local message="$1"
|
|
59
|
+
# Replace newlines with spaces, remove extra whitespace, truncate if too long
|
|
60
|
+
echo "$message" | tr '\n' ' ' | tr -s ' ' | cut -c1-500
|
|
61
|
+
}
|
|
62
|
+
|
|
56
63
|
# Validate package.json exists
|
|
57
64
|
if [ ! -f "package.json" ]; then
|
|
58
65
|
error_message="❌ ERROR: package.json not found in current directory. Make sure you're running this action in a directory with a package.json file"
|
|
59
66
|
echo "$error_message"
|
|
60
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
67
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
61
68
|
exit 1
|
|
62
69
|
fi
|
|
63
70
|
|
|
@@ -65,7 +72,7 @@ runs:
|
|
|
65
72
|
if ! jq empty package.json 2>/dev/null; then
|
|
66
73
|
error_message="❌ ERROR: package.json is not valid JSON"
|
|
67
74
|
echo "$error_message"
|
|
68
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
75
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
69
76
|
exit 1
|
|
70
77
|
fi
|
|
71
78
|
|
|
@@ -74,7 +81,7 @@ runs:
|
|
|
74
81
|
if [ -z "$package_name" ] || [ "$package_name" = "null" ]; then
|
|
75
82
|
error_message="❌ ERROR: package.json must have a 'name' field"
|
|
76
83
|
echo "$error_message"
|
|
77
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
84
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
78
85
|
exit 1
|
|
79
86
|
fi
|
|
80
87
|
|
|
@@ -104,29 +111,29 @@ runs:
|
|
|
104
111
|
if [ $version_exit_code -ne 0 ]; then
|
|
105
112
|
error_message="❌ ERROR: Failed to update package version. Check if the version format is valid. Error: $version_output"
|
|
106
113
|
echo "$error_message"
|
|
107
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
114
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
108
115
|
exit 1
|
|
109
116
|
fi
|
|
110
117
|
|
|
111
118
|
# Publish package based on detected package manager
|
|
112
119
|
case "$package_manager" in
|
|
113
120
|
"yarn")
|
|
114
|
-
publish_output=$(yarn publish --access public --tag pr --new-version $version --no-git-tag-version 2>&1)
|
|
121
|
+
publish_output=$(yarn publish --access public --tag pr --new-version $version --no-git-tag-version --skip-check-working-tree 2>&1)
|
|
115
122
|
publish_exit_code=$?
|
|
116
123
|
if [ $publish_exit_code -ne 0 ]; then
|
|
117
124
|
error_message="❌ ERROR: Failed to publish package with yarn. Error: $publish_output"
|
|
118
125
|
echo "$error_message"
|
|
119
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
126
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
120
127
|
exit 1
|
|
121
128
|
fi
|
|
122
129
|
;;
|
|
123
130
|
"pnpm")
|
|
124
|
-
publish_output=$(pnpm publish --access public --tag pr 2>&1)
|
|
131
|
+
publish_output=$(pnpm publish --no-git-checks --access public --tag pr 2>&1)
|
|
125
132
|
publish_exit_code=$?
|
|
126
133
|
if [ $publish_exit_code -ne 0 ]; then
|
|
127
134
|
error_message="❌ ERROR: Failed to publish package with pnpm. Error: $publish_output"
|
|
128
135
|
echo "$error_message"
|
|
129
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
136
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
130
137
|
exit 1
|
|
131
138
|
fi
|
|
132
139
|
;;
|
|
@@ -136,7 +143,7 @@ runs:
|
|
|
136
143
|
if [ $publish_exit_code -ne 0 ]; then
|
|
137
144
|
error_message="❌ ERROR: Failed to publish package with npm. Error: $publish_output"
|
|
138
145
|
echo "$error_message"
|
|
139
|
-
echo "error-message=$error_message" >> $GITHUB_OUTPUT
|
|
146
|
+
echo "error-message=$(sanitize_error "$error_message")" >> $GITHUB_OUTPUT
|
|
140
147
|
exit 1
|
|
141
148
|
fi
|
|
142
149
|
;;
|
|
@@ -148,7 +155,7 @@ runs:
|
|
|
148
155
|
PR: ${{ github.event.number }}
|
|
149
156
|
SHA: ${{ github.event.pull_request.head.sha }}
|
|
150
157
|
|
|
151
|
-
- uses: codfish/actions/comment@
|
|
158
|
+
- uses: codfish/actions/comment@v2
|
|
152
159
|
if: failure() && inputs.comment == 'true'
|
|
153
160
|
with:
|
|
154
161
|
message: |
|
|
@@ -156,16 +163,16 @@ runs:
|
|
|
156
163
|
|
|
157
164
|
Error: ${{ steps.publish.outputs.error-message }}
|
|
158
165
|
|
|
159
|
-
|
|
166
|
+
📋 [View workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details.
|
|
160
167
|
upsert: true
|
|
161
168
|
tag: ${{ inputs.comment-tag }}
|
|
162
169
|
|
|
163
|
-
- uses: codfish/actions/comment@
|
|
170
|
+
- uses: codfish/actions/comment@v2
|
|
164
171
|
if: success() && inputs.comment == 'true'
|
|
165
172
|
with:
|
|
166
173
|
message: |
|
|
167
174
|
✅ **PR package published successfully!**
|
|
168
175
|
|
|
169
|
-
Install with:
|
|
176
|
+
Install with: <code>npm install ${{ steps.publish.outputs.package-name }}@${{ steps.publish.outputs.version }}</code>
|
|
170
177
|
upsert: true
|
|
171
178
|
tag: ${{ inputs.comment-tag }}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# setup-node-and-install
|
|
2
2
|
|
|
3
3
|
Sets up Node.js environment and installs dependencies with automatic package manager detection, intelligent caching, and
|
|
4
|
-
|
|
4
|
+
dynamic Node version detection via the `node-version` input, `.node-version`, `.nvmrc`, or `package.json` `volta.node`.
|
|
5
5
|
|
|
6
6
|
This action provides the following functionality:
|
|
7
7
|
|
|
8
8
|
- Automatically detects package manager (npm, yarn, or pnpm) from lockfiles
|
|
9
9
|
- Uses GitHub's official `setup-node` action with optimized caching
|
|
10
10
|
- Installs dependencies with appropriate commands based on detected package manager
|
|
11
|
-
- Supports
|
|
11
|
+
- Supports `.node-version`, `.nvmrc`, and `package.json` `volta.node` for version specification
|
|
12
12
|
- Intelligent caching of node_modules when lockfiles are present
|
|
13
13
|
|
|
14
14
|
<!-- DOCTOC SKIP -->
|
|
@@ -22,7 +22,7 @@ steps:
|
|
|
22
22
|
- uses: actions/checkout@v5
|
|
23
23
|
|
|
24
24
|
# will install latest Node v18.x
|
|
25
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
25
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
26
26
|
with:
|
|
27
27
|
node-version: 18
|
|
28
28
|
cache-key-suffix: '-${{ github.head_ref || github.event.release.tag_name }}'
|
|
@@ -30,8 +30,10 @@ steps:
|
|
|
30
30
|
- run: npm test
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
-
The `node-version` input is optional. If not supplied, this action will attempt to
|
|
34
|
-
|
|
33
|
+
The `node-version` input is optional. If not supplied, this action will attempt to resolve a version using, in order:
|
|
34
|
+
|
|
35
|
+
1. `.node-version`, 2) `.nvmrc`, 3) `package.json` `volta.node`. If none are present, `actions/setup-node` runs without
|
|
36
|
+
an explicit version and will use its default behavior.
|
|
35
37
|
|
|
36
38
|
The `cache-key-suffix` input is optional. If not supplied, no suffix will be applied to the cache key used to restore
|
|
37
39
|
cache in subsequent workflow runs.
|
|
@@ -50,7 +52,7 @@ v18.14.1
|
|
|
50
52
|
steps:
|
|
51
53
|
- uses: actions/checkout@v5
|
|
52
54
|
# will install Node v18.14.1
|
|
53
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
55
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
54
56
|
- run: npm test
|
|
55
57
|
```
|
|
56
58
|
|
|
@@ -65,29 +67,29 @@ steps:
|
|
|
65
67
|
steps:
|
|
66
68
|
- uses: actions/checkout@v5
|
|
67
69
|
# will install Node v20.10.0
|
|
68
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
70
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
69
71
|
- run: npm test
|
|
70
72
|
```
|
|
71
73
|
|
|
72
|
-
## Node Version
|
|
74
|
+
## Node Version Resolution Priority
|
|
73
75
|
|
|
74
76
|
When multiple version specification methods are present, the action uses this priority order:
|
|
75
77
|
|
|
76
78
|
1. **Input parameter** (`node-version`) - highest priority
|
|
77
|
-
2. **`.
|
|
78
|
-
3. **`.
|
|
79
|
-
4.
|
|
79
|
+
2. **`.node-version` file**
|
|
80
|
+
3. **`.nvmrc` file**
|
|
81
|
+
4. **`package.json` `volta.node` property**
|
|
82
|
+
5. **`actions/setup-node` default behavior** when no version is specified
|
|
80
83
|
|
|
81
84
|
## Inputs
|
|
82
85
|
|
|
83
86
|
<!-- start inputs -->
|
|
84
87
|
|
|
85
|
-
| Input | Description
|
|
86
|
-
| ------------------- |
|
|
87
|
-
| `node-version` | Node.js version to install (e.g.
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `working-directory` | Directory containing package.json and lockfile | No | `.` |
|
|
88
|
+
| Input | Description | Required | Default |
|
|
89
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | -------- | ------- |
|
|
90
|
+
| `node-version` | Node.js version to install (e.g. "24", "lts/\*"). Precedence: node-version input > .node-version > .nvmrc > package.json volta.node. | No | - |
|
|
91
|
+
| `install-options` | Extra command-line options to pass to npm/pnpm/yarn install. | No | - |
|
|
92
|
+
| `working-directory` | Directory containing package.json and lockfile. | No | `.` |
|
|
91
93
|
|
|
92
94
|
<!-- end inputs -->
|
|
93
95
|
|
|
@@ -103,7 +105,7 @@ The action automatically detects your package manager:
|
|
|
103
105
|
### With specific Node version
|
|
104
106
|
|
|
105
107
|
```yaml
|
|
106
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
108
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
107
109
|
with:
|
|
108
110
|
node-version: '18'
|
|
109
111
|
```
|
|
@@ -111,7 +113,7 @@ The action automatically detects your package manager:
|
|
|
111
113
|
### With pnpm in subdirectory
|
|
112
114
|
|
|
113
115
|
```yaml
|
|
114
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
116
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
115
117
|
with:
|
|
116
118
|
working-directory: './frontend'
|
|
117
119
|
install-options: '--frozen-lockfile'
|
|
@@ -120,7 +122,7 @@ The action automatically detects your package manager:
|
|
|
120
122
|
### With custom cache key
|
|
121
123
|
|
|
122
124
|
```yaml
|
|
123
|
-
- uses: codfish/actions/setup-node-and-install@
|
|
125
|
+
- uses: codfish/actions/setup-node-and-install@v2
|
|
124
126
|
with:
|
|
125
127
|
cache-key-suffix: '-${{ github.head_ref }}'
|
|
126
128
|
```
|
|
@@ -135,5 +137,5 @@ Replace multiple setup steps with this single action:
|
|
|
135
137
|
- node-version-file: '.nvmrc'
|
|
136
138
|
- cache: 'npm'
|
|
137
139
|
- - run: npm ci --prefer-offline --no-audit
|
|
138
|
-
+ - uses: codfish/actions/setup-node-and-install@
|
|
140
|
+
+ - uses: codfish/actions/setup-node-and-install@v2
|
|
139
141
|
```
|