exportVariable function

void exportVariable({
  1. required String name,
  2. required Object value,
})

Sets env variable for this action and future actions in the job.

Implementation

void exportVariable({required String name, required Object value}) {
  final convertedVal = toCommandValue(value);

  final filePath = environmentVariables['GITHUB_ENV'] ?? '';
  if (filePath.isNotEmpty) {
    const delimiter = '_GitHubActionsFileCommandDelimeter_';
    const separator = '\n';
    final commandValue =
        '$name<<$delimiter$separator$convertedVal$separator$delimiter';
    issueFileCommand('ENV', commandValue);
  } else {
    issueCommand('set-env', {'name': name}, convertedVal);
  }

  updateEnvironmentVariableCache(name: name, value: convertedVal);
}