Send the version and mode with the user agent
This commit changes the way the action determines if running in action or runner mode. There is now an environment variable that is set at the beginning of the process and elsewhere in the process, we can check to see if the variable is set.
This commit is contained in:
parent
fad7cc482d
commit
47588796b4
48 changed files with 361 additions and 224 deletions
20
lib/toolcache.js
generated
20
lib/toolcache.js
generated
|
|
@ -15,6 +15,7 @@ const io = __importStar(require("@actions/io"));
|
|||
const actionsToolcache = __importStar(require("@actions/tool-cache"));
|
||||
const safeWhich = __importStar(require("@chrisgavin/safe-which"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const actions_util_1 = require("./actions-util");
|
||||
/*
|
||||
* This file acts as an interface to the functionality of the actions toolcache.
|
||||
* That library is not safe to use outside of actions as it makes assumptions about
|
||||
|
|
@ -34,8 +35,8 @@ const semver = __importStar(require("semver"));
|
|||
* @param logger logger to use
|
||||
* @returns path to the destination directory
|
||||
*/
|
||||
async function extractTar(file, mode, tempDir, logger) {
|
||||
if (mode === "actions") {
|
||||
async function extractTar(file, tempDir, logger) {
|
||||
if (actions_util_1.isActions()) {
|
||||
return await actionsToolcache.extractTar(file);
|
||||
}
|
||||
else {
|
||||
|
|
@ -94,8 +95,8 @@ exports.extractTar = extractTar;
|
|||
* @param toolCacheDir path to the tool cache directory
|
||||
* @param logger logger to use
|
||||
*/
|
||||
async function cacheDir(sourceDir, tool, version, mode, toolCacheDir, logger) {
|
||||
if (mode === "actions") {
|
||||
async function cacheDir(sourceDir, tool, version, toolCacheDir, logger) {
|
||||
if (actions_util_1.isActions()) {
|
||||
return await actionsToolcache.cacheDir(sourceDir, tool, version);
|
||||
}
|
||||
else {
|
||||
|
|
@ -132,8 +133,8 @@ exports.cacheDir = cacheDir;
|
|||
* @param toolCacheDir path to the tool cache directory
|
||||
* @param logger logger to use
|
||||
*/
|
||||
function find(toolName, versionSpec, mode, toolCacheDir, logger) {
|
||||
if (mode === "actions") {
|
||||
function find(toolName, versionSpec, toolCacheDir, logger) {
|
||||
if (actions_util_1.isActions()) {
|
||||
return actionsToolcache.find(toolName, versionSpec);
|
||||
}
|
||||
else {
|
||||
|
|
@ -147,7 +148,7 @@ function find(toolName, versionSpec, mode, toolCacheDir, logger) {
|
|||
const arch = os.arch();
|
||||
// attempt to resolve an explicit version
|
||||
if (!isExplicitVersion(versionSpec, logger)) {
|
||||
const localVersions = findAllVersions(toolName, mode, toolCacheDir, logger);
|
||||
const localVersions = findAllVersions(toolName, toolCacheDir, logger);
|
||||
const match = evaluateVersions(localVersions, versionSpec, logger);
|
||||
versionSpec = match;
|
||||
}
|
||||
|
|
@ -175,12 +176,11 @@ exports.find = find;
|
|||
* Also see findAllVersions function from node_modules/@actions/tool-cache/lib/tool-cache.d.ts
|
||||
*
|
||||
* @param toolName name of the tool
|
||||
* @param mode should run the actions or runner implementation
|
||||
* @param toolCacheDir path to the tool cache directory
|
||||
* @param logger logger to use
|
||||
*/
|
||||
function findAllVersions(toolName, mode, toolCacheDir, logger) {
|
||||
if (mode === "actions") {
|
||||
function findAllVersions(toolName, toolCacheDir, logger) {
|
||||
if (actions_util_1.isActions()) {
|
||||
return actionsToolcache.findAllVersions(toolName);
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue