Updated check
This commit is contained in:
parent
d1e3ff806a
commit
2eb11f64a4
16
dist/index.js
generated
vendored
16
dist/index.js
generated
vendored
@ -1526,7 +1526,13 @@ function run() {
|
|||||||
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
||||||
const inputs = (0, inputs_1.getInputs)();
|
const inputs = (0, inputs_1.getInputs)();
|
||||||
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
||||||
if (inputs.token && env.GITHUB_EVENT_PULL_REQUEST_NUMBER) {
|
const hasGitDirectory = yield (0, utils_1.hasLocalGitDirectory)({
|
||||||
|
workingDirectory: env.GITHUB_WORKSPACE || process.cwd()
|
||||||
|
});
|
||||||
|
if (inputs.token &&
|
||||||
|
env.GITHUB_EVENT_PULL_REQUEST_NUMBER &&
|
||||||
|
!hasGitDirectory) {
|
||||||
|
core.info('Running via REST API');
|
||||||
const unsupportedInputs = [
|
const unsupportedInputs = [
|
||||||
'sha',
|
'sha',
|
||||||
'baseSha',
|
'baseSha',
|
||||||
@ -1550,6 +1556,7 @@ function run() {
|
|||||||
yield getChangedFilesFromRESTAPI({ inputs, env });
|
yield getChangedFilesFromRESTAPI({ inputs, env });
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
core.info('Running via local git');
|
||||||
yield getChangedFilesFromLocalGit({ inputs, env });
|
yield getChangedFilesFromLocalGit({ inputs, env });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1626,7 +1633,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
exports.hasLocalGitDirectory = exports.recoverDeletedFiles = exports.setOutput = exports.getYamlFilePatterns = exports.getFilePatterns = exports.jsonOutput = exports.getDirnameMaxDepth = exports.canDiffCommits = exports.getPreviousGitTag = exports.verifyCommitSha = exports.getParentSha = exports.getRemoteBranchHeadSha = exports.getHeadSha = exports.gitLog = exports.getFilteredChangedFiles = exports.getAllChangedFiles = exports.gitRenamedFiles = exports.gitSubmoduleDiffSHA = exports.getSubmodulePath = exports.gitFetchSubmodules = exports.gitFetch = exports.submoduleExists = exports.isRepoShallow = exports.updateGitGlobalConfig = exports.verifyMinimumGitVersion = void 0;
|
||||||
/*global AsyncIterableIterator*/
|
/*global AsyncIterableIterator*/
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
@ -2329,6 +2336,11 @@ const recoverDeletedFiles = ({ inputs, workingDirectory, deletedFiles, sha }) =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
exports.recoverDeletedFiles = recoverDeletedFiles;
|
exports.recoverDeletedFiles = recoverDeletedFiles;
|
||||||
|
const hasLocalGitDirectory = ({ workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const gitDirectory = path.join(workingDirectory, '.git');
|
||||||
|
return yield exists(gitDirectory);
|
||||||
|
});
|
||||||
|
exports.hasLocalGitDirectory = hasLocalGitDirectory;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
12
src/main.ts
12
src/main.ts
@ -17,6 +17,7 @@ import {
|
|||||||
getFilePatterns,
|
getFilePatterns,
|
||||||
getSubmodulePath,
|
getSubmodulePath,
|
||||||
getYamlFilePatterns,
|
getYamlFilePatterns,
|
||||||
|
hasLocalGitDirectory,
|
||||||
isRepoShallow,
|
isRepoShallow,
|
||||||
setOutput,
|
setOutput,
|
||||||
submoduleExists,
|
submoduleExists,
|
||||||
@ -276,8 +277,16 @@ export async function run(): Promise<void> {
|
|||||||
core.debug(`Env: ${JSON.stringify(env, null, 2)}`)
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`)
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
||||||
|
const hasGitDirectory = await hasLocalGitDirectory({
|
||||||
|
workingDirectory: env.GITHUB_WORKSPACE || process.cwd()
|
||||||
|
})
|
||||||
|
|
||||||
if (inputs.token && env.GITHUB_EVENT_PULL_REQUEST_NUMBER) {
|
if (
|
||||||
|
inputs.token &&
|
||||||
|
env.GITHUB_EVENT_PULL_REQUEST_NUMBER &&
|
||||||
|
!hasGitDirectory
|
||||||
|
) {
|
||||||
|
core.info('Running via REST API')
|
||||||
const unsupportedInputs: (keyof Inputs)[] = [
|
const unsupportedInputs: (keyof Inputs)[] = [
|
||||||
'sha',
|
'sha',
|
||||||
'baseSha',
|
'baseSha',
|
||||||
@ -301,6 +310,7 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await getChangedFilesFromRESTAPI({inputs, env})
|
await getChangedFilesFromRESTAPI({inputs, env})
|
||||||
} else {
|
} else {
|
||||||
|
core.info('Running via local git')
|
||||||
await getChangedFilesFromLocalGit({inputs, env})
|
await getChangedFilesFromLocalGit({inputs, env})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1097,3 +1097,12 @@ export const recoverDeletedFiles = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const hasLocalGitDirectory = async ({
|
||||||
|
workingDirectory
|
||||||
|
}: {
|
||||||
|
workingDirectory: string
|
||||||
|
}): Promise<boolean> => {
|
||||||
|
const gitDirectory = path.join(workingDirectory, '.git')
|
||||||
|
return await exists(gitDirectory)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user