diff options
Diffstat (limited to 'pkg/runner/testdata/actions-environment-and-context-tests/js/index.js')
-rw-r--r-- | pkg/runner/testdata/actions-environment-and-context-tests/js/index.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/pkg/runner/testdata/actions-environment-and-context-tests/js/index.js b/pkg/runner/testdata/actions-environment-and-context-tests/js/index.js new file mode 100644 index 0000000..79d8d06 --- /dev/null +++ b/pkg/runner/testdata/actions-environment-and-context-tests/js/index.js @@ -0,0 +1,15 @@ +function checkEnvVar({ name, allowEmpty }) { + if ( + process.env[name] === undefined || + (allowEmpty === false && process.env[name] === "") + ) { + throw new Error( + `${name} is undefined` + (allowEmpty === false ? " or empty" : "") + ); + } + console.log(`${name}=${process.env[name]}`); +} + +checkEnvVar({ name: "GITHUB_ACTION", allowEmpty: false }); +checkEnvVar({ name: "GITHUB_ACTION_REPOSITORY", allowEmpty: true /* allows to be empty for local actions */ }); +checkEnvVar({ name: "GITHUB_ACTION_REF", allowEmpty: true /* allows to be empty for local actions */ }); |