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

View File

@ -2,9 +2,13 @@ import { assert } from 'console';
import fs from 'fs'; import fs from 'fs';
import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system'; import { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger'; import CloudRunnerLogger from '../cloud-runner/services/cloud-runner-logger';
import Input from '../input';
export class GitRepoReader { export class GitRepoReader {
public static async GetRemote() { public static async GetRemote() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
assert(fs.existsSync(`.git`)); assert(fs.existsSync(`.git`));
const value = (await CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``); const value = (await CloudRunnerSystem.Run(`git remote -v`, false, true)).replace(/ /g, ``);
CloudRunnerLogger.log(`value ${value}`); CloudRunnerLogger.log(`value ${value}`);
@ -14,6 +18,9 @@ export class GitRepoReader {
} }
public static async GetBranch() { public static async GetBranch() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
assert(fs.existsSync(`.git`)); assert(fs.existsSync(`.git`));
return (await CloudRunnerSystem.Run(`git branch --show-current`, false, true)) 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 { CloudRunnerSystem } from '../cloud-runner/services/cloud-runner-system';
import * as core from '@actions/core'; import * as core from '@actions/core';
import Input from '../input';
export class GithubCliReader { export class GithubCliReader {
static async GetGitHubAuthToken() { static async GetGitHubAuthToken() {
if (Input.cloudRunnerCluster === 'local') {
return '';
}
try { try {
const authStatus = await CloudRunnerSystem.Run(`gh auth status`, true, true); const authStatus = await CloudRunnerSystem.Run(`gh auth status`, true, true);
if (authStatus.includes('You are not logged') || authStatus === '') { if (authStatus.includes('You are not logged') || authStatus === '') {

View File

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