-
Notifications
You must be signed in to change notification settings - Fork 0
Add variable_prefix input; upgrade to node24 + bump deps #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
89692c9
6e292ad
5b9ddd2
d145b9e
417c283
8575b6d
a989876
1821fdc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -201,3 +201,32 @@ jobs: | |
| ``` | ||
|
|
||
| In this workflow, `env1:value1`, `env2:value2` and `env3:value3` export as env. | ||
|
|
||
| ### Prefixing exported variable names | ||
|
|
||
| Use `variable_prefix` to prepend a string to every exported variable name. This | ||
| is useful for namespacing exports to avoid collisions with variables from other | ||
| steps. The prefix is concatenated literally, so include any separator yourself. | ||
|
|
||
| ```yaml | ||
| on: [push] | ||
| name: Prefixed exports | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: kanga333/variable-mapper@master | ||
| with: | ||
| key: 'first' | ||
| map: | | ||
| { | ||
| "first": { | ||
| "env1": "value1", | ||
| "env2": "value2" | ||
| } | ||
| } | ||
| export_to: env | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion (demonstrate the docs claim): The action input description and PR body emphasize that |
||
| variable_prefix: 'MYAPP_' | ||
| - run: echo $MYAPP_env1 $MYAPP_env2 | ||
| ``` | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,18 @@ describe('exporter', () => { | |
| exporter.exportLog('key', 'value') | ||
| assertWriteCalls([`export key: value${os.EOL}`]) | ||
| }) | ||
|
|
||
| it('getExporters applies prefix to log exporter', () => { | ||
| const [logExporter] = exporter.getExporters('log', 'MYAPP_') | ||
| logExporter('key', 'value') | ||
| assertWriteCalls([`export MYAPP_key: value${os.EOL}`]) | ||
| }) | ||
|
|
||
| it('getExporters omits prefix when empty', () => { | ||
| const [logExporter] = exporter.getExporters('log', '') | ||
| logExporter('key', 'value') | ||
| assertWriteCalls([`export key: value${os.EOL}`]) | ||
| }) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion (coverage): Both new tests exercise only the |
||
| }) | ||
|
|
||
| // Assert that process.stdout.write calls called only with the given arguments. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,6 +20,12 @@ inputs: | |
| Specify the behavior of getting the variable. first_match, overwrite and | ||
| fill are valid values. | ||
| default: 'first_match' | ||
| variable_prefix: | ||
| description: | | ||
| Optional prefix prepended to every exported variable name (across log, | ||
| env and output targets). Useful for avoiding collisions. The value is | ||
| concatenated literally, so include any separator yourself (e.g. "MYAPP_"). | ||
| default: '' | ||
| runs: | ||
| using: 'node20' | ||
| using: 'node24' | ||
| main: 'dist/index.js' | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question: Worth verifying in the testing step that GitHub Actions has Node 24 GA as a supported |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion (consistency): This new example uses
kanga333/variable-mapper@master, but the integration-test workflow now usessagansystems/variable-mapper@masterfor its readme-example jobs. The rest of the README still referenceskanga333, so matching the existing convention is defensible — but since you're adding a brand-new section in this PR, it would be a good moment to usesagansystems/variable-mapper@masterhere (and optionally do a one-pass update of the older examples in the same commit). Folks copy/pasting from README expect the example to point at the fork they're consuming.