github.com/nektos/act@v0.2.63-0.20240520024548-8acde99bfa9c/pkg/runner/testdata/actions-environment-and-context-tests/js/index.js (about)

     1  function checkEnvVar({ name, allowEmpty }) {
     2    if (
     3      process.env[name] === undefined ||
     4      (allowEmpty === false && process.env[name] === "")
     5    ) {
     6      throw new Error(
     7        `${name} is undefined` + (allowEmpty === false ? " or empty" : "")
     8      );
     9    }
    10    console.log(`${name}=${process.env[name]}`);
    11  }
    12  
    13  checkEnvVar({ name: "GITHUB_ACTION", allowEmpty: false });
    14  checkEnvVar({ name: "GITHUB_ACTION_REPOSITORY", allowEmpty: true /* allows to be empty for local actions */ });
    15  checkEnvVar({ name: "GITHUB_ACTION_REF", allowEmpty: true /* allows to be empty for local actions */ });