skip all input readers when cloud runner is local

pull/387/head
Frostebite 2022-04-21 20:16:43 +01:00
parent 5ee7fe517e
commit 165e4b1772
6 changed files with 46 additions and 1 deletions

25
dist/index.js vendored
View File

@ -4755,12 +4755,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GenericInputReader = void 0;
const cloud_runner_system_1 = __nccwpck_require__(99393);
const input_1 = __importDefault(__nccwpck_require__(91933));
class GenericInputReader {
static Run(command) {
return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') {
return '';
}
return yield cloud_runner_system_1.CloudRunnerSystem.Run(command, false, true);
});
}
@ -4793,9 +4800,13 @@ const console_1 = __nccwpck_require__(96206);
const fs_1 = __importDefault(__nccwpck_require__(57147));
const cloud_runner_system_1 = __nccwpck_require__(99393);
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
const input_1 = __importDefault(__nccwpck_require__(91933));
class GitRepoReader {
static GetRemote() {
return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') {
return '';
}
console_1.assert(fs_1.default.existsSync(`.git`));
const value = (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
cloud_runner_logger_1.default.log(`value ${value}`);
@ -4805,6 +4816,9 @@ class GitRepoReader {
}
static GetBranch() {
return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') {
return '';
}
console_1.assert(fs_1.default.existsSync(`.git`));
return (yield cloud_runner_system_1.CloudRunnerSystem.Run(`git branch --show-current`, false, true))
.split('\n')[0]
@ -4851,13 +4865,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.GithubCliReader = void 0;
const cloud_runner_system_1 = __nccwpck_require__(99393);
const core = __importStar(__nccwpck_require__(42186));
const input_1 = __importDefault(__nccwpck_require__(91933));
class GithubCliReader {
static GetGitHubAuthToken() {
return __awaiter(this, void 0, void 0, function* () {
if (input_1.default.cloudRunnerCluster === 'local') {
return '';
}
try {
const authStatus = yield cloud_runner_system_1.CloudRunnerSystem.Run(`gh auth status`, true, true);
if (authStatus.includes('You are not logged') || authStatus === '') {
@ -4893,7 +4914,11 @@ exports.ReadLicense = void 0;
const path_1 = __importDefault(__nccwpck_require__(71017));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const yaml_1 = __importDefault(__nccwpck_require__(44603));
const input_1 = __importDefault(__nccwpck_require__(91933));
function ReadLicense() {
if (input_1.default.cloudRunnerCluster === 'local') {
return '';
}
const pipelineFile = path_1.default.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);
return fs_1.default.existsSync(pipelineFile) ? yaml_1.default.parse(fs_1.default.readFileSync(pipelineFile, 'utf8')).env.UNITY_LICENSE : '';
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,12 @@
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import Input from '../input';
export class GenericInputReader {
public static async Run(command) {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
return await CloudRunnerSystem.Run(command, false, true);
}
}

View File

@ -2,9 +2,13 @@ import { assert } from 'console';
import fs from 'fs';
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
import Input from '../input';
export class GitRepoReader {
public static async GetRemote() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
assert(fs.existsSync(`.git`));
const value = (await CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
CloudRunnerLogger.log(`value ${value}`);
@ -14,6 +18,9 @@ export class GitRepoReader {
}
public static async GetBranch() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
assert(fs.existsSync(`.git`));
return (await CloudRunnerSystem.Run(`git branch --show-current`, false, true))

View File

@ -1,8 +1,12 @@
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import * as core from '@actions/core';
import Input from '../input';
export class GithubCliReader {
static async GetGitHubAuthToken() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
try {
const authStatus = await CloudRunnerSystem.Run(`gh auth status`, true, true);
if (authStatus.includes('You are not logged') || authStatus === '') {

View File

@ -1,8 +1,12 @@
import path from 'path';
import fs from 'fs';
import YAML from 'yaml';
import Input from '../input';
export function ReadLicense() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
const pipelineFile = path.join(__dirname, `.github`, `workflows`, `cloud-runner-k8s-pipeline.yml`);
return fs.existsSync(pipelineFile) ? YAML.parse(fs.readFileSync(pipelineFile, 'utf8')).env.UNITY_LICENSE : '';