chore: switch to use the github context (#1386)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
e3ea6b7948
commit
ec0b6d0e4c
128
dist/index.js
generated
vendored
128
dist/index.js
generated
vendored
@ -52,9 +52,9 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|||||||
exports.getChangedFilesFromGithubAPI = exports.getAllChangeTypeFiles = exports.getChangeTypeFiles = exports.getAllDiffFiles = exports.ChangeTypeEnum = exports.getRenamedFiles = void 0;
|
exports.getChangedFilesFromGithubAPI = exports.getAllChangeTypeFiles = exports.getChangeTypeFiles = exports.getAllDiffFiles = exports.ChangeTypeEnum = exports.getRenamedFiles = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const github = __importStar(__nccwpck_require__(5438));
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
|
const flatten_1 = __importDefault(__nccwpck_require__(2394));
|
||||||
const path = __importStar(__nccwpck_require__(1017));
|
const path = __importStar(__nccwpck_require__(1017));
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
const flatten_1 = __importDefault(__nccwpck_require__(2394));
|
|
||||||
const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, diffResult, submodulePaths }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
const renamedFiles = yield (0, utils_1.gitRenamedFiles)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
@ -213,8 +213,9 @@ const getAllChangeTypeFiles = ({ inputs, changedFiles }) => __awaiter(void 0, vo
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
exports.getAllChangeTypeFiles = getAllChangeTypeFiles;
|
exports.getAllChangeTypeFiles = getAllChangeTypeFiles;
|
||||||
const getChangedFilesFromGithubAPI = ({ inputs, env }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromGithubAPI = ({ inputs }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _a, e_1, _b, _c;
|
var _a, e_1, _b, _c;
|
||||||
|
var _d;
|
||||||
const octokit = github.getOctokit(inputs.token, {
|
const octokit = github.getOctokit(inputs.token, {
|
||||||
baseUrl: inputs.apiUrl
|
baseUrl: inputs.apiUrl
|
||||||
});
|
});
|
||||||
@ -232,7 +233,7 @@ const getChangedFilesFromGithubAPI = ({ inputs, env }) => __awaiter(void 0, void
|
|||||||
const options = octokit.rest.pulls.listFiles.endpoint.merge({
|
const options = octokit.rest.pulls.listFiles.endpoint.merge({
|
||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
pull_number: env.GITHUB_EVENT_PULL_REQUEST_NUMBER,
|
pull_number: (_d = github.context.payload.pull_request) === null || _d === void 0 ? void 0 : _d.number,
|
||||||
per_page: 100
|
per_page: 100
|
||||||
});
|
});
|
||||||
const paginatedResponse = yield octokit.paginate(options);
|
const paginatedResponse = yield octokit.paginate(options);
|
||||||
@ -247,9 +248,9 @@ const getChangedFilesFromGithubAPI = ({ inputs, env }) => __awaiter(void 0, void
|
|||||||
unchanged: ChangeTypeEnum.Unmerged
|
unchanged: ChangeTypeEnum.Unmerged
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
for (var _d = true, paginatedResponse_1 = __asyncValues(paginatedResponse), paginatedResponse_1_1; paginatedResponse_1_1 = yield paginatedResponse_1.next(), _a = paginatedResponse_1_1.done, !_a; _d = true) {
|
for (var _e = true, paginatedResponse_1 = __asyncValues(paginatedResponse), paginatedResponse_1_1; paginatedResponse_1_1 = yield paginatedResponse_1.next(), _a = paginatedResponse_1_1.done, !_a; _e = true) {
|
||||||
_c = paginatedResponse_1_1.value;
|
_c = paginatedResponse_1_1.value;
|
||||||
_d = false;
|
_e = false;
|
||||||
const item = _c;
|
const item = _c;
|
||||||
const changeType = statusMap[item.status] || ChangeTypeEnum.Unknown;
|
const changeType = statusMap[item.status] || ChangeTypeEnum.Unknown;
|
||||||
if (changeType === ChangeTypeEnum.Renamed) {
|
if (changeType === ChangeTypeEnum.Renamed) {
|
||||||
@ -269,7 +270,7 @@ const getChangedFilesFromGithubAPI = ({ inputs, env }) => __awaiter(void 0, void
|
|||||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
finally {
|
finally {
|
||||||
try {
|
try {
|
||||||
if (!_d && !_a && (_b = paginatedResponse_1.return)) yield _b.call(paginatedResponse_1);
|
if (!_e && !_a && (_b = paginatedResponse_1.return)) yield _b.call(paginatedResponse_1);
|
||||||
}
|
}
|
||||||
finally { if (e_1) throw e_1.error; }
|
finally { if (e_1) throw e_1.error; }
|
||||||
}
|
}
|
||||||
@ -344,7 +345,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Added]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Added]
|
||||||
});
|
});
|
||||||
core.debug(`Added files: ${addedFiles}`);
|
core.debug(`Added files: ${JSON.stringify(addedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('added_files', outputPrefix),
|
key: getOutputKey('added_files', outputPrefix),
|
||||||
value: addedFiles.paths,
|
value: addedFiles.paths,
|
||||||
@ -360,7 +361,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Copied]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Copied]
|
||||||
});
|
});
|
||||||
core.debug(`Copied files: ${copiedFiles}`);
|
core.debug(`Copied files: ${JSON.stringify(copiedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('copied_files', outputPrefix),
|
key: getOutputKey('copied_files', outputPrefix),
|
||||||
value: copiedFiles.paths,
|
value: copiedFiles.paths,
|
||||||
@ -376,7 +377,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Modified]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Modified]
|
||||||
});
|
});
|
||||||
core.debug(`Modified files: ${modifiedFiles}`);
|
core.debug(`Modified files: ${JSON.stringify(modifiedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('modified_files', outputPrefix),
|
key: getOutputKey('modified_files', outputPrefix),
|
||||||
value: modifiedFiles.paths,
|
value: modifiedFiles.paths,
|
||||||
@ -392,7 +393,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Renamed]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Renamed]
|
||||||
});
|
});
|
||||||
core.debug(`Renamed files: ${renamedFiles}`);
|
core.debug(`Renamed files: ${JSON.stringify(renamedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('renamed_files', outputPrefix),
|
key: getOutputKey('renamed_files', outputPrefix),
|
||||||
value: renamedFiles.paths,
|
value: renamedFiles.paths,
|
||||||
@ -408,7 +409,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.TypeChanged]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.TypeChanged]
|
||||||
});
|
});
|
||||||
core.debug(`Type changed files: ${typeChangedFiles}`);
|
core.debug(`Type changed files: ${JSON.stringify(typeChangedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('type_changed_files', outputPrefix),
|
key: getOutputKey('type_changed_files', outputPrefix),
|
||||||
value: typeChangedFiles.paths,
|
value: typeChangedFiles.paths,
|
||||||
@ -424,7 +425,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Unmerged]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Unmerged]
|
||||||
});
|
});
|
||||||
core.debug(`Unmerged files: ${unmergedFiles}`);
|
core.debug(`Unmerged files: ${JSON.stringify(unmergedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('unmerged_files', outputPrefix),
|
key: getOutputKey('unmerged_files', outputPrefix),
|
||||||
value: unmergedFiles.paths,
|
value: unmergedFiles.paths,
|
||||||
@ -440,7 +441,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Unknown]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Unknown]
|
||||||
});
|
});
|
||||||
core.debug(`Unknown files: ${unknownFiles}`);
|
core.debug(`Unknown files: ${JSON.stringify(unknownFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('unknown_files', outputPrefix),
|
key: getOutputKey('unknown_files', outputPrefix),
|
||||||
value: unknownFiles.paths,
|
value: unknownFiles.paths,
|
||||||
@ -455,7 +456,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
inputs,
|
inputs,
|
||||||
changedFiles: allFilteredDiffFiles
|
changedFiles: allFilteredDiffFiles
|
||||||
});
|
});
|
||||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`);
|
core.debug(`All changed and modified files: ${JSON.stringify(allChangedAndModifiedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
||||||
value: allChangedAndModifiedFiles.paths,
|
value: allChangedAndModifiedFiles.paths,
|
||||||
@ -476,7 +477,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles_1.ChangeTypeEnum.Renamed
|
changedFiles_1.ChangeTypeEnum.Renamed
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All changed files: ${allChangedFiles}`);
|
core.debug(`All changed files: ${JSON.stringify(allChangedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('all_changed_files', outputPrefix),
|
key: getOutputKey('all_changed_files', outputPrefix),
|
||||||
value: allChangedFiles.paths,
|
value: allChangedFiles.paths,
|
||||||
@ -502,7 +503,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles_1.ChangeTypeEnum.Renamed
|
changedFiles_1.ChangeTypeEnum.Renamed
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All other changed files: ${allOtherChangedFiles}`);
|
core.debug(`All other changed files: ${JSON.stringify(allOtherChangedFiles)}`);
|
||||||
const otherChangedFiles = allOtherChangedFiles.paths
|
const otherChangedFiles = allOtherChangedFiles.paths
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
.filter((filePath) => !allChangedFiles.paths.split(inputs.separator).includes(filePath));
|
.filter((filePath) => !allChangedFiles.paths.split(inputs.separator).includes(filePath));
|
||||||
@ -535,7 +536,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles_1.ChangeTypeEnum.Deleted
|
changedFiles_1.ChangeTypeEnum.Deleted
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
core.debug(`All modified files: ${allModifiedFiles}`);
|
core.debug(`All modified files: ${JSON.stringify(allModifiedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('all_modified_files', outputPrefix),
|
key: getOutputKey('all_modified_files', outputPrefix),
|
||||||
value: allModifiedFiles.paths,
|
value: allModifiedFiles.paths,
|
||||||
@ -588,7 +589,7 @@ const setChangedFilesOutput = ({ allDiffFiles, inputs, workingDirectory, diffRes
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted]
|
changeTypes: [changedFiles_1.ChangeTypeEnum.Deleted]
|
||||||
});
|
});
|
||||||
core.debug(`Deleted files: ${deletedFiles}`);
|
core.debug(`Deleted files: ${JSON.stringify(deletedFiles)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: getOutputKey('deleted_files', outputPrefix),
|
key: getOutputKey('deleted_files', outputPrefix),
|
||||||
value: deletedFiles.paths,
|
value: deletedFiles.paths,
|
||||||
@ -676,8 +677,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getSHAForPullRequestEvent = exports.getSHAForPushEvent = void 0;
|
exports.getSHAForPullRequestEvent = exports.getSHAForPushEvent = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
const getCurrentSHA = ({ env, inputs, workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCurrentSHA = ({ inputs, workingDirectory }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var _a, _b, _c, _d, _e, _f;
|
||||||
let currentSha = inputs.sha;
|
let currentSha = inputs.sha;
|
||||||
core.debug('Getting current SHA...');
|
core.debug('Getting current SHA...');
|
||||||
if (inputs.until) {
|
if (inputs.until) {
|
||||||
@ -703,13 +706,13 @@ const getCurrentSHA = ({ env, inputs, workingDirectory }) => __awaiter(void 0, v
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!currentSha) {
|
if (!currentSha) {
|
||||||
if (env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA &&
|
if (((_b = (_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.sha) &&
|
||||||
(yield (0, utils_1.verifyCommitSha)({
|
(yield (0, utils_1.verifyCommitSha)({
|
||||||
sha: env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA,
|
sha: (_d = (_c = github.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.head) === null || _d === void 0 ? void 0 : _d.sha,
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
showAsErrorMessage: false
|
showAsErrorMessage: false
|
||||||
})) === 0) {
|
})) === 0) {
|
||||||
currentSha = env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA;
|
currentSha = (_f = (_e = github.context.payload.pull_request) === null || _e === void 0 ? void 0 : _e.head) === null || _f === void 0 ? void 0 : _f.sha;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
currentSha = yield (0, utils_1.getHeadSha)({ cwd: workingDirectory });
|
currentSha = yield (0, utils_1.getHeadSha)({ cwd: workingDirectory });
|
||||||
@ -721,14 +724,15 @@ const getCurrentSHA = ({ env, inputs, workingDirectory }) => __awaiter(void 0, v
|
|||||||
return currentSha;
|
return currentSha;
|
||||||
});
|
});
|
||||||
const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () {
|
const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, isTag) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
var _g;
|
||||||
let targetBranch = env.GITHUB_REF_NAME;
|
let targetBranch = env.GITHUB_REF_NAME;
|
||||||
const currentBranch = targetBranch;
|
const currentBranch = targetBranch;
|
||||||
let initialCommit = false;
|
let initialCommit = false;
|
||||||
if (isShallow && !inputs.skipInitialFetch) {
|
if (isShallow && !inputs.skipInitialFetch) {
|
||||||
core.info('Repository is shallow, fetching more history...');
|
core.info('Repository is shallow, fetching more history...');
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
const sourceBranch = env.GITHUB_EVENT_BASE_REF.replace('refs/heads/', '') ||
|
const sourceBranch = github.context.payload.base_ref.replace('refs/heads/', '') ||
|
||||||
env.GITHUB_EVENT_RELEASE_TARGET_COMMITISH;
|
((_g = github.context.payload.release) === null || _g === void 0 ? void 0 : _g.target_commitish);
|
||||||
yield (0, utils_1.gitFetch)({
|
yield (0, utils_1.gitFetch)({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -766,7 +770,7 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const currentSha = yield getCurrentSHA({ env, inputs, workingDirectory });
|
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
||||||
let previousSha = inputs.baseSha;
|
let previousSha = inputs.baseSha;
|
||||||
const diff = '..';
|
const diff = '..';
|
||||||
if (previousSha && currentSha && currentBranch && targetBranch) {
|
if (previousSha && currentSha && currentBranch && targetBranch) {
|
||||||
@ -812,8 +816,9 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.debug('Getting previous SHA for last remote commit...');
|
core.debug('Getting previous SHA for last remote commit...');
|
||||||
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
|
if (github.context.payload.forced === 'false' ||
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE;
|
!github.context.payload.forced) {
|
||||||
|
previousSha = github.context.payload.before;
|
||||||
}
|
}
|
||||||
if (!previousSha ||
|
if (!previousSha ||
|
||||||
previousSha === '0000000000000000000000000000000000000000') {
|
previousSha === '0000000000000000000000000000000000000000') {
|
||||||
@ -863,8 +868,9 @@ const getSHAForPushEvent = (inputs, env, workingDirectory, isShallow, hasSubmodu
|
|||||||
});
|
});
|
||||||
exports.getSHAForPushEvent = getSHAForPushEvent;
|
exports.getSHAForPushEvent = getSHAForPushEvent;
|
||||||
const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
let targetBranch = env.GITHUB_EVENT_PULL_REQUEST_BASE_REF;
|
var _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
||||||
const currentBranch = env.GITHUB_EVENT_PULL_REQUEST_HEAD_REF;
|
let targetBranch = (_j = (_h = github.context.payload.pull_request) === null || _h === void 0 ? void 0 : _h.base) === null || _j === void 0 ? void 0 : _j.ref;
|
||||||
|
const currentBranch = (_l = (_k = github.context.payload.pull_request) === null || _k === void 0 ? void 0 : _k.head) === null || _l === void 0 ? void 0 : _l.ref;
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
targetBranch = currentBranch;
|
targetBranch = currentBranch;
|
||||||
}
|
}
|
||||||
@ -877,7 +883,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
'origin',
|
'origin',
|
||||||
`pull/${env.GITHUB_EVENT_PULL_REQUEST_NUMBER}/head:${currentBranch}`
|
`pull/${(_m = github.context.payload.pull_request) === null || _m === void 0 ? void 0 : _m.number}/head:${currentBranch}`
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
if (prFetchExitCode !== 0) {
|
if (prFetchExitCode !== 0) {
|
||||||
@ -923,7 +929,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
}
|
}
|
||||||
core.info('Completed fetching more history.');
|
core.info('Completed fetching more history.');
|
||||||
}
|
}
|
||||||
const currentSha = yield getCurrentSHA({ env, inputs, workingDirectory });
|
const currentSha = yield getCurrentSHA({ inputs, workingDirectory });
|
||||||
let previousSha = inputs.baseSha;
|
let previousSha = inputs.baseSha;
|
||||||
let diff = '...';
|
let diff = '...';
|
||||||
if (previousSha && currentSha && currentBranch && targetBranch) {
|
if (previousSha && currentSha && currentBranch && targetBranch) {
|
||||||
@ -942,13 +948,13 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
diff
|
diff
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF ||
|
if (!((_p = (_o = github.context.payload.pull_request) === null || _o === void 0 ? void 0 : _o.base) === null || _p === void 0 ? void 0 : _p.ref) ||
|
||||||
env.GITHUB_EVENT_HEAD_REPO_FORK === 'true') {
|
((_r = (_q = github.context.payload.head) === null || _q === void 0 ? void 0 : _q.repo) === null || _r === void 0 ? void 0 : _r.fork) === 'true') {
|
||||||
diff = '..';
|
diff = '..';
|
||||||
}
|
}
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE;
|
previousSha = github.context.payload.before;
|
||||||
if (!previousSha ||
|
if (!previousSha ||
|
||||||
(previousSha &&
|
(previousSha &&
|
||||||
(yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory })) !==
|
(yield (0, utils_1.verifyCommitSha)({ sha: previousSha, cwd: workingDirectory })) !==
|
||||||
@ -959,7 +965,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
});
|
});
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
core.warning('Unable to locate the previous commit in the local history. Falling back to the pull request base sha.');
|
core.warning('Unable to locate the previous commit in the local history. Falling back to the pull request base sha.');
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
previousSha = (_t = (_s = github.context.payload.pull_request) === null || _s === void 0 ? void 0 : _s.base) === null || _t === void 0 ? void 0 : _t.sha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -969,7 +975,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
branch: targetBranch
|
branch: targetBranch
|
||||||
});
|
});
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
previousSha = (_v = (_u = github.context.payload.pull_request) === null || _u === void 0 ? void 0 : _u.base) === null || _v === void 0 ? void 0 : _v.sha;
|
||||||
}
|
}
|
||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
if (!(yield (0, utils_1.canDiffCommits)({
|
if (!(yield (0, utils_1.canDiffCommits)({
|
||||||
@ -1006,7 +1012,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!previousSha || previousSha === currentSha) {
|
if (!previousSha || previousSha === currentSha) {
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA;
|
previousSha = (_x = (_w = github.context.payload.pull_request) === null || _w === void 0 ? void 0 : _w.base) === null || _x === void 0 ? void 0 : _x.sha;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(yield (0, utils_1.canDiffCommits)({
|
if (!(yield (0, utils_1.canDiffCommits)({
|
||||||
@ -1039,7 +1045,7 @@ const getSHAForPullRequestEvent = (inputs, env, workingDirectory, isShallow, has
|
|||||||
// uses: actions/checkout@v3
|
// uses: actions/checkout@v3
|
||||||
// with:
|
// with:
|
||||||
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
if (env.GITHUB_EVENT_NAME === 'pull_request_target') {
|
if (github.context.eventName === 'pull_request_target') {
|
||||||
core.warning('If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.');
|
core.warning('If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.');
|
||||||
core.warning('This can be done by setting actions/checkout `repository` to ${{ github.event.pull_request.head.repo.full_name }}');
|
core.warning('This can be done by setting actions/checkout `repository` to ${{ github.event.pull_request.head.repo.full_name }}');
|
||||||
}
|
}
|
||||||
@ -1100,35 +1106,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getEnv = void 0;
|
exports.getEnv = void 0;
|
||||||
const fs_1 = __nccwpck_require__(7147);
|
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
|
const getEnv = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
core.debug(`Process Env: ${JSON.stringify(process.env, null, 2)}`);
|
||||||
const eventPath = process.env.GITHUB_EVENT_PATH;
|
|
||||||
let eventJson = {};
|
|
||||||
if (eventPath) {
|
|
||||||
eventJson = JSON.parse(yield fs_1.promises.readFile(eventPath, { encoding: 'utf8' }));
|
|
||||||
}
|
|
||||||
core.debug(`Env: ${JSON.stringify(process.env, null, 2)}`);
|
|
||||||
core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`);
|
|
||||||
return {
|
return {
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: ((_b = (_a = eventJson.pull_request) === null || _a === void 0 ? void 0 : _a.head) === null || _b === void 0 ? void 0 : _b.ref) || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_REF: ((_d = (_c = eventJson.pull_request) === null || _c === void 0 ? void 0 : _c.base) === null || _d === void 0 ? void 0 : _d.ref) || '',
|
|
||||||
GITHUB_EVENT_BEFORE: eventJson.before || '',
|
|
||||||
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
|
|
||||||
GITHUB_EVENT_RELEASE_TARGET_COMMITISH: ((_e = eventJson.release) === null || _e === void 0 ? void 0 : _e.target_commitish) || '',
|
|
||||||
GITHUB_EVENT_HEAD_REPO_FORK: ((_g = (_f = eventJson.head) === null || _f === void 0 ? void 0 : _f.repo) === null || _g === void 0 ? void 0 : _g.fork) || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: ((_h = eventJson.pull_request) === null || _h === void 0 ? void 0 : _h.number) || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: ((_k = (_j = eventJson.pull_request) === null || _j === void 0 ? void 0 : _j.base) === null || _k === void 0 ? void 0 : _k.sha) || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: ((_m = (_l = eventJson.pull_request) === null || _l === void 0 ? void 0 : _l.head) === null || _m === void 0 ? void 0 : _m.sha) || '',
|
|
||||||
GITHUB_EVENT_FORCED: eventJson.forced || '',
|
|
||||||
GITHUB_EVENT_ACTION: eventJson.action || '',
|
|
||||||
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
||||||
GITHUB_REF: process.env.GITHUB_REF || '',
|
GITHUB_REF: process.env.GITHUB_REF || '',
|
||||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '',
|
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
|
||||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || '',
|
|
||||||
GITHUB_REPOSITORY_OWNER: process.env.GITHUB_REPOSITORY_OWNER || '',
|
|
||||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || ''
|
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
exports.getEnv = getEnv;
|
exports.getEnv = getEnv;
|
||||||
@ -1347,6 +1331,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
|
const github = __importStar(__nccwpck_require__(5438));
|
||||||
const path_1 = __importDefault(__nccwpck_require__(1017));
|
const path_1 = __importDefault(__nccwpck_require__(1017));
|
||||||
const changedFiles_1 = __nccwpck_require__(7358);
|
const changedFiles_1 = __nccwpck_require__(7358);
|
||||||
const changedFilesOutput_1 = __nccwpck_require__(8930);
|
const changedFilesOutput_1 = __nccwpck_require__(8930);
|
||||||
@ -1355,7 +1340,7 @@ const env_1 = __nccwpck_require__(9763);
|
|||||||
const inputs_1 = __nccwpck_require__(6180);
|
const inputs_1 = __nccwpck_require__(6180);
|
||||||
const utils_1 = __nccwpck_require__(918);
|
const utils_1 = __nccwpck_require__(918);
|
||||||
const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
var _a;
|
var _a, _b, _c;
|
||||||
yield (0, utils_1.verifyMinimumGitVersion)();
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
||||||
let quotePathValue = 'on';
|
let quotePathValue = 'on';
|
||||||
if (!inputs.quotePath) {
|
if (!inputs.quotePath) {
|
||||||
@ -1384,12 +1369,12 @@ const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatter
|
|||||||
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
gitFetchExtraArgs = ['--prune', '--no-recurse-submodules'];
|
||||||
}
|
}
|
||||||
let diffResult;
|
let diffResult;
|
||||||
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF) {
|
if (!((_c = (_b = github.context.payload.pull_request) === null || _b === void 0 ? void 0 : _b.base) === null || _c === void 0 ? void 0 : _c.ref)) {
|
||||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'push'} event...`);
|
core.info(`Running on a ${github.context.eventName || 'push'} event...`);
|
||||||
diffResult = yield (0, commitSha_1.getSHAForPushEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, isTag);
|
diffResult = yield (0, commitSha_1.getSHAForPushEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs, isTag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'pull_request'} (${env.GITHUB_EVENT_ACTION}) event...`);
|
core.info(`Running on a ${github.context.eventName || 'pull_request'} (${github.context.payload.action}) event...`);
|
||||||
diffResult = yield (0, commitSha_1.getSHAForPullRequestEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs);
|
diffResult = yield (0, commitSha_1.getSHAForPullRequestEvent)(inputs, env, workingDirectory, isShallow, hasSubmodule, gitFetchExtraArgs);
|
||||||
}
|
}
|
||||||
if (diffResult.initialCommit) {
|
if (diffResult.initialCommit) {
|
||||||
@ -1470,10 +1455,9 @@ const getChangedFilesFromLocalGit = ({ inputs, env, workingDirectory, filePatter
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const getChangedFilesFromRESTAPI = ({ inputs, env, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
const getChangedFilesFromRESTAPI = ({ inputs, workingDirectory, filePatterns, yamlFilePatterns }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
const allDiffFiles = yield (0, changedFiles_1.getChangedFilesFromGithubAPI)({
|
||||||
inputs,
|
inputs
|
||||||
env
|
|
||||||
});
|
});
|
||||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`);
|
||||||
core.info('All Done!');
|
core.info('All Done!');
|
||||||
@ -1514,12 +1498,15 @@ const getChangedFilesFromRESTAPI = ({ inputs, env, workingDirectory, filePattern
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
function run() {
|
function run() {
|
||||||
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
core.startGroup('changed-files');
|
core.startGroup('changed-files');
|
||||||
const env = yield (0, env_1.getEnv)();
|
const env = yield (0, env_1.getEnv)();
|
||||||
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)}`);
|
||||||
|
const githubContext = github.context;
|
||||||
|
core.debug(`Github Context: ${JSON.stringify(githubContext, null, 2)}`);
|
||||||
const workingDirectory = path_1.default.resolve(env.GITHUB_WORKSPACE || process.cwd(), inputs.path);
|
const workingDirectory = path_1.default.resolve(env.GITHUB_WORKSPACE || process.cwd(), inputs.path);
|
||||||
core.debug(`Working directory: ${workingDirectory}`);
|
core.debug(`Working directory: ${workingDirectory}`);
|
||||||
const hasGitDirectory = yield (0, utils_1.hasLocalGitDirectory)({ workingDirectory });
|
const hasGitDirectory = yield (0, utils_1.hasLocalGitDirectory)({ workingDirectory });
|
||||||
@ -1535,7 +1522,7 @@ function run() {
|
|||||||
});
|
});
|
||||||
core.debug(`Yaml file patterns: ${JSON.stringify(yamlFilePatterns)}`);
|
core.debug(`Yaml file patterns: ${JSON.stringify(yamlFilePatterns)}`);
|
||||||
if (inputs.token &&
|
if (inputs.token &&
|
||||||
env.GITHUB_EVENT_PULL_REQUEST_NUMBER &&
|
((_a = github.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.number) &&
|
||||||
!hasGitDirectory) {
|
!hasGitDirectory) {
|
||||||
core.info("Using GitHub's REST API to get changed files");
|
core.info("Using GitHub's REST API to get changed files");
|
||||||
const unsupportedInputs = [
|
const unsupportedInputs = [
|
||||||
@ -1555,7 +1542,6 @@ function run() {
|
|||||||
}
|
}
|
||||||
yield getChangedFilesFromRESTAPI({
|
yield getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
|
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
@ -1,19 +1,18 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as github from '@actions/github'
|
import * as github from '@actions/github'
|
||||||
import type {RestEndpointMethodTypes} from '@octokit/rest'
|
import type {RestEndpointMethodTypes} from '@octokit/rest'
|
||||||
|
import flatten from 'lodash/flatten'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
|
||||||
import {DiffResult} from './commitSha'
|
import {DiffResult} from './commitSha'
|
||||||
import {Env} from './env'
|
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
import {
|
import {
|
||||||
|
getAllChangedFiles,
|
||||||
getDirnameMaxDepth,
|
getDirnameMaxDepth,
|
||||||
gitRenamedFiles,
|
gitRenamedFiles,
|
||||||
gitSubmoduleDiffSHA,
|
gitSubmoduleDiffSHA,
|
||||||
jsonOutput,
|
jsonOutput
|
||||||
getAllChangedFiles
|
|
||||||
} from './utils'
|
} from './utils'
|
||||||
import flatten from 'lodash/flatten'
|
|
||||||
|
|
||||||
export const getRenamedFiles = async ({
|
export const getRenamedFiles = async ({
|
||||||
inputs,
|
inputs,
|
||||||
@ -252,11 +251,9 @@ export const getAllChangeTypeFiles = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const getChangedFilesFromGithubAPI = async ({
|
export const getChangedFilesFromGithubAPI = async ({
|
||||||
inputs,
|
inputs
|
||||||
env
|
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
env: Env
|
|
||||||
}): Promise<ChangedFiles> => {
|
}): Promise<ChangedFiles> => {
|
||||||
const octokit = github.getOctokit(inputs.token, {
|
const octokit = github.getOctokit(inputs.token, {
|
||||||
baseUrl: inputs.apiUrl
|
baseUrl: inputs.apiUrl
|
||||||
@ -277,7 +274,7 @@ export const getChangedFilesFromGithubAPI = async ({
|
|||||||
const options = octokit.rest.pulls.listFiles.endpoint.merge({
|
const options = octokit.rest.pulls.listFiles.endpoint.merge({
|
||||||
owner: github.context.repo.owner,
|
owner: github.context.repo.owner,
|
||||||
repo: github.context.repo.repo,
|
repo: github.context.repo.repo,
|
||||||
pull_number: env.GITHUB_EVENT_PULL_REQUEST_NUMBER,
|
pull_number: github.context.payload.pull_request?.number,
|
||||||
per_page: 100
|
per_page: 100
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Added]
|
changeTypes: [ChangeTypeEnum.Added]
|
||||||
})
|
})
|
||||||
core.debug(`Added files: ${addedFiles}`)
|
core.debug(`Added files: ${JSON.stringify(addedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('added_files', outputPrefix),
|
key: getOutputKey('added_files', outputPrefix),
|
||||||
value: addedFiles.paths,
|
value: addedFiles.paths,
|
||||||
@ -65,7 +65,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Copied]
|
changeTypes: [ChangeTypeEnum.Copied]
|
||||||
})
|
})
|
||||||
core.debug(`Copied files: ${copiedFiles}`)
|
core.debug(`Copied files: ${JSON.stringify(copiedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('copied_files', outputPrefix),
|
key: getOutputKey('copied_files', outputPrefix),
|
||||||
value: copiedFiles.paths,
|
value: copiedFiles.paths,
|
||||||
@ -83,7 +83,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Modified]
|
changeTypes: [ChangeTypeEnum.Modified]
|
||||||
})
|
})
|
||||||
core.debug(`Modified files: ${modifiedFiles}`)
|
core.debug(`Modified files: ${JSON.stringify(modifiedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('modified_files', outputPrefix),
|
key: getOutputKey('modified_files', outputPrefix),
|
||||||
value: modifiedFiles.paths,
|
value: modifiedFiles.paths,
|
||||||
@ -101,7 +101,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Renamed]
|
changeTypes: [ChangeTypeEnum.Renamed]
|
||||||
})
|
})
|
||||||
core.debug(`Renamed files: ${renamedFiles}`)
|
core.debug(`Renamed files: ${JSON.stringify(renamedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('renamed_files', outputPrefix),
|
key: getOutputKey('renamed_files', outputPrefix),
|
||||||
value: renamedFiles.paths,
|
value: renamedFiles.paths,
|
||||||
@ -119,7 +119,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.TypeChanged]
|
changeTypes: [ChangeTypeEnum.TypeChanged]
|
||||||
})
|
})
|
||||||
core.debug(`Type changed files: ${typeChangedFiles}`)
|
core.debug(`Type changed files: ${JSON.stringify(typeChangedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('type_changed_files', outputPrefix),
|
key: getOutputKey('type_changed_files', outputPrefix),
|
||||||
value: typeChangedFiles.paths,
|
value: typeChangedFiles.paths,
|
||||||
@ -137,7 +137,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Unmerged]
|
changeTypes: [ChangeTypeEnum.Unmerged]
|
||||||
})
|
})
|
||||||
core.debug(`Unmerged files: ${unmergedFiles}`)
|
core.debug(`Unmerged files: ${JSON.stringify(unmergedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('unmerged_files', outputPrefix),
|
key: getOutputKey('unmerged_files', outputPrefix),
|
||||||
value: unmergedFiles.paths,
|
value: unmergedFiles.paths,
|
||||||
@ -155,7 +155,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Unknown]
|
changeTypes: [ChangeTypeEnum.Unknown]
|
||||||
})
|
})
|
||||||
core.debug(`Unknown files: ${unknownFiles}`)
|
core.debug(`Unknown files: ${JSON.stringify(unknownFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('unknown_files', outputPrefix),
|
key: getOutputKey('unknown_files', outputPrefix),
|
||||||
value: unknownFiles.paths,
|
value: unknownFiles.paths,
|
||||||
@ -172,7 +172,11 @@ export const setChangedFilesOutput = async ({
|
|||||||
inputs,
|
inputs,
|
||||||
changedFiles: allFilteredDiffFiles
|
changedFiles: allFilteredDiffFiles
|
||||||
})
|
})
|
||||||
core.debug(`All changed and modified files: ${allChangedAndModifiedFiles}`)
|
core.debug(
|
||||||
|
`All changed and modified files: ${JSON.stringify(
|
||||||
|
allChangedAndModifiedFiles
|
||||||
|
)}`
|
||||||
|
)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
key: getOutputKey('all_changed_and_modified_files', outputPrefix),
|
||||||
value: allChangedAndModifiedFiles.paths,
|
value: allChangedAndModifiedFiles.paths,
|
||||||
@ -195,7 +199,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
ChangeTypeEnum.Renamed
|
ChangeTypeEnum.Renamed
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All changed files: ${allChangedFiles}`)
|
core.debug(`All changed files: ${JSON.stringify(allChangedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('all_changed_files', outputPrefix),
|
key: getOutputKey('all_changed_files', outputPrefix),
|
||||||
value: allChangedFiles.paths,
|
value: allChangedFiles.paths,
|
||||||
@ -224,7 +228,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
ChangeTypeEnum.Renamed
|
ChangeTypeEnum.Renamed
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All other changed files: ${allOtherChangedFiles}`)
|
core.debug(`All other changed files: ${JSON.stringify(allOtherChangedFiles)}`)
|
||||||
|
|
||||||
const otherChangedFiles = allOtherChangedFiles.paths
|
const otherChangedFiles = allOtherChangedFiles.paths
|
||||||
.split(inputs.separator)
|
.split(inputs.separator)
|
||||||
@ -267,7 +271,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
ChangeTypeEnum.Deleted
|
ChangeTypeEnum.Deleted
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
core.debug(`All modified files: ${allModifiedFiles}`)
|
core.debug(`All modified files: ${JSON.stringify(allModifiedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('all_modified_files', outputPrefix),
|
key: getOutputKey('all_modified_files', outputPrefix),
|
||||||
value: allModifiedFiles.paths,
|
value: allModifiedFiles.paths,
|
||||||
@ -333,7 +337,7 @@ export const setChangedFilesOutput = async ({
|
|||||||
changedFiles: allFilteredDiffFiles,
|
changedFiles: allFilteredDiffFiles,
|
||||||
changeTypes: [ChangeTypeEnum.Deleted]
|
changeTypes: [ChangeTypeEnum.Deleted]
|
||||||
})
|
})
|
||||||
core.debug(`Deleted files: ${deletedFiles}`)
|
core.debug(`Deleted files: ${JSON.stringify(deletedFiles)}`)
|
||||||
await setOutput({
|
await setOutput({
|
||||||
key: getOutputKey('deleted_files', outputPrefix),
|
key: getOutputKey('deleted_files', outputPrefix),
|
||||||
value: deletedFiles.paths,
|
value: deletedFiles.paths,
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as github from '@actions/github'
|
||||||
|
|
||||||
import {Env} from './env'
|
import {Env} from './env'
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
@ -15,11 +16,9 @@ import {
|
|||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
const getCurrentSHA = async ({
|
const getCurrentSHA = async ({
|
||||||
env,
|
|
||||||
inputs,
|
inputs,
|
||||||
workingDirectory
|
workingDirectory
|
||||||
}: {
|
}: {
|
||||||
env: Env
|
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
}): Promise<string> => {
|
}): Promise<string> => {
|
||||||
@ -50,14 +49,14 @@ const getCurrentSHA = async ({
|
|||||||
} else {
|
} else {
|
||||||
if (!currentSha) {
|
if (!currentSha) {
|
||||||
if (
|
if (
|
||||||
env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA &&
|
github.context.payload.pull_request?.head?.sha &&
|
||||||
(await verifyCommitSha({
|
(await verifyCommitSha({
|
||||||
sha: env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA,
|
sha: github.context.payload.pull_request?.head?.sha,
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
showAsErrorMessage: false
|
showAsErrorMessage: false
|
||||||
})) === 0
|
})) === 0
|
||||||
) {
|
) {
|
||||||
currentSha = env.GITHUB_EVENT_PULL_REQUEST_HEAD_SHA
|
currentSha = github.context.payload.pull_request?.head?.sha
|
||||||
} else {
|
} else {
|
||||||
currentSha = await getHeadSha({cwd: workingDirectory})
|
currentSha = await getHeadSha({cwd: workingDirectory})
|
||||||
}
|
}
|
||||||
@ -97,8 +96,8 @@ export const getSHAForPushEvent = async (
|
|||||||
|
|
||||||
if (isTag) {
|
if (isTag) {
|
||||||
const sourceBranch =
|
const sourceBranch =
|
||||||
env.GITHUB_EVENT_BASE_REF.replace('refs/heads/', '') ||
|
github.context.payload.base_ref.replace('refs/heads/', '') ||
|
||||||
env.GITHUB_EVENT_RELEASE_TARGET_COMMITISH
|
github.context.payload.release?.target_commitish
|
||||||
await gitFetch({
|
await gitFetch({
|
||||||
cwd: workingDirectory,
|
cwd: workingDirectory,
|
||||||
args: [
|
args: [
|
||||||
@ -137,7 +136,7 @@ export const getSHAForPushEvent = async (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentSha = await getCurrentSHA({env, inputs, workingDirectory})
|
const currentSha = await getCurrentSHA({inputs, workingDirectory})
|
||||||
let previousSha = inputs.baseSha
|
let previousSha = inputs.baseSha
|
||||||
const diff = '..'
|
const diff = '..'
|
||||||
|
|
||||||
@ -191,8 +190,11 @@ export const getSHAForPushEvent = async (
|
|||||||
targetBranch = tag
|
targetBranch = tag
|
||||||
} else {
|
} else {
|
||||||
core.debug('Getting previous SHA for last remote commit...')
|
core.debug('Getting previous SHA for last remote commit...')
|
||||||
if (env.GITHUB_EVENT_FORCED === 'false' || !env.GITHUB_EVENT_FORCED) {
|
if (
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE
|
github.context.payload.forced === 'false' ||
|
||||||
|
!github.context.payload.forced
|
||||||
|
) {
|
||||||
|
previousSha = github.context.payload.before
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -265,8 +267,8 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
hasSubmodule: boolean,
|
hasSubmodule: boolean,
|
||||||
gitFetchExtraArgs: string[]
|
gitFetchExtraArgs: string[]
|
||||||
): Promise<DiffResult> => {
|
): Promise<DiffResult> => {
|
||||||
let targetBranch = env.GITHUB_EVENT_PULL_REQUEST_BASE_REF
|
let targetBranch = github.context.payload.pull_request?.base?.ref
|
||||||
const currentBranch = env.GITHUB_EVENT_PULL_REQUEST_HEAD_REF
|
const currentBranch = github.context.payload.pull_request?.head?.ref
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
targetBranch = currentBranch
|
targetBranch = currentBranch
|
||||||
}
|
}
|
||||||
@ -281,7 +283,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
'-u',
|
'-u',
|
||||||
'--progress',
|
'--progress',
|
||||||
'origin',
|
'origin',
|
||||||
`pull/${env.GITHUB_EVENT_PULL_REQUEST_NUMBER}/head:${currentBranch}`
|
`pull/${github.context.payload.pull_request?.number}/head:${currentBranch}`
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -334,7 +336,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
core.info('Completed fetching more history.')
|
core.info('Completed fetching more history.')
|
||||||
}
|
}
|
||||||
|
|
||||||
const currentSha = await getCurrentSHA({env, inputs, workingDirectory})
|
const currentSha = await getCurrentSHA({inputs, workingDirectory})
|
||||||
let previousSha = inputs.baseSha
|
let previousSha = inputs.baseSha
|
||||||
let diff = '...'
|
let diff = '...'
|
||||||
|
|
||||||
@ -362,15 +364,15 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF ||
|
!github.context.payload.pull_request?.base?.ref ||
|
||||||
env.GITHUB_EVENT_HEAD_REPO_FORK === 'true'
|
github.context.payload.head?.repo?.fork === 'true'
|
||||||
) {
|
) {
|
||||||
diff = '..'
|
diff = '..'
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
if (inputs.sinceLastRemoteCommit) {
|
if (inputs.sinceLastRemoteCommit) {
|
||||||
previousSha = env.GITHUB_EVENT_BEFORE
|
previousSha = github.context.payload.before
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!previousSha ||
|
!previousSha ||
|
||||||
@ -389,7 +391,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
core.warning(
|
core.warning(
|
||||||
'Unable to locate the previous commit in the local history. Falling back to the pull request base sha.'
|
'Unable to locate the previous commit in the local history. Falling back to the pull request base sha.'
|
||||||
)
|
)
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
previousSha = github.context.payload.pull_request?.base?.sha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -399,7 +401,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (!previousSha) {
|
if (!previousSha) {
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
previousSha = github.context.payload.pull_request?.base?.sha
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
@ -449,7 +451,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!previousSha || previousSha === currentSha) {
|
if (!previousSha || previousSha === currentSha) {
|
||||||
previousSha = env.GITHUB_EVENT_PULL_REQUEST_BASE_SHA
|
previousSha = github.context.payload.pull_request?.base?.sha
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +496,7 @@ export const getSHAForPullRequestEvent = async (
|
|||||||
// uses: actions/checkout@v3
|
// uses: actions/checkout@v3
|
||||||
// with:
|
// with:
|
||||||
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
// repository: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
if (env.GITHUB_EVENT_NAME === 'pull_request_target') {
|
if (github.context.eventName === 'pull_request_target') {
|
||||||
core.warning(
|
core.warning(
|
||||||
'If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.'
|
'If this pull request is from a forked repository, please set the checkout action `repository` input to the same repository as the pull request.'
|
||||||
)
|
)
|
||||||
|
68
src/env.ts
68
src/env.ts
@ -1,80 +1,16 @@
|
|||||||
import {promises as fs} from 'fs'
|
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
export type Env = {
|
export type Env = {
|
||||||
GITHUB_REF_NAME: string
|
GITHUB_REF_NAME: string
|
||||||
GITHUB_REF: string
|
GITHUB_REF: string
|
||||||
GITHUB_WORKSPACE: string
|
GITHUB_WORKSPACE: string
|
||||||
GITHUB_EVENT_ACTION: string
|
|
||||||
GITHUB_EVENT_NAME: string
|
|
||||||
GITHUB_EVENT_FORCED: string
|
|
||||||
GITHUB_EVENT_BEFORE: string
|
|
||||||
GITHUB_EVENT_BASE_REF: string
|
|
||||||
GITHUB_EVENT_RELEASE_TARGET_COMMITISH: string
|
|
||||||
GITHUB_EVENT_HEAD_REPO_FORK: string
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: string
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: string
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: string
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: string
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_REF: string
|
|
||||||
GITHUB_REPOSITORY_OWNER: string
|
|
||||||
GITHUB_REPOSITORY: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GithubEvent = {
|
|
||||||
action?: string
|
|
||||||
forced?: string
|
|
||||||
pull_request?: {
|
|
||||||
head: {
|
|
||||||
ref: string
|
|
||||||
sha: string
|
|
||||||
}
|
|
||||||
base: {
|
|
||||||
ref: string
|
|
||||||
sha: string
|
|
||||||
}
|
|
||||||
number: string
|
|
||||||
}
|
|
||||||
release?: {
|
|
||||||
target_commitish: string
|
|
||||||
}
|
|
||||||
before?: string
|
|
||||||
base_ref?: string
|
|
||||||
head?: {
|
|
||||||
repo?: {
|
|
||||||
fork: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getEnv = async (): Promise<Env> => {
|
export const getEnv = async (): Promise<Env> => {
|
||||||
const eventPath = process.env.GITHUB_EVENT_PATH
|
core.debug(`Process Env: ${JSON.stringify(process.env, null, 2)}`)
|
||||||
let eventJson: GithubEvent = {}
|
|
||||||
|
|
||||||
if (eventPath) {
|
|
||||||
eventJson = JSON.parse(await fs.readFile(eventPath, {encoding: 'utf8'}))
|
|
||||||
}
|
|
||||||
core.debug(`Env: ${JSON.stringify(process.env, null, 2)}`)
|
|
||||||
core.debug(`Event: ${JSON.stringify(eventJson, null, 2)}`)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_REF: eventJson.pull_request?.head?.ref || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_REF: eventJson.pull_request?.base?.ref || '',
|
|
||||||
GITHUB_EVENT_BEFORE: eventJson.before || '',
|
|
||||||
GITHUB_EVENT_BASE_REF: eventJson.base_ref || '',
|
|
||||||
GITHUB_EVENT_RELEASE_TARGET_COMMITISH:
|
|
||||||
eventJson.release?.target_commitish || '',
|
|
||||||
GITHUB_EVENT_HEAD_REPO_FORK: eventJson.head?.repo?.fork || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_NUMBER: eventJson.pull_request?.number || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_BASE_SHA: eventJson.pull_request?.base?.sha || '',
|
|
||||||
GITHUB_EVENT_PULL_REQUEST_HEAD_SHA: eventJson.pull_request?.head?.sha || '',
|
|
||||||
GITHUB_EVENT_FORCED: eventJson.forced || '',
|
|
||||||
GITHUB_EVENT_ACTION: eventJson.action || '',
|
|
||||||
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
GITHUB_REF_NAME: process.env.GITHUB_REF_NAME || '',
|
||||||
GITHUB_REF: process.env.GITHUB_REF || '',
|
GITHUB_REF: process.env.GITHUB_REF || '',
|
||||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || '',
|
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE || ''
|
||||||
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || '',
|
|
||||||
GITHUB_REPOSITORY_OWNER: process.env.GITHUB_REPOSITORY_OWNER || '',
|
|
||||||
GITHUB_REPOSITORY: process.env.GITHUB_REPOSITORY || ''
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
src/main.ts
20
src/main.ts
@ -1,4 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import * as github from '@actions/github'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import {
|
import {
|
||||||
getAllDiffFiles,
|
getAllDiffFiles,
|
||||||
@ -76,8 +77,8 @@ const getChangedFilesFromLocalGit = async ({
|
|||||||
|
|
||||||
let diffResult: DiffResult
|
let diffResult: DiffResult
|
||||||
|
|
||||||
if (!env.GITHUB_EVENT_PULL_REQUEST_BASE_REF) {
|
if (!github.context.payload.pull_request?.base?.ref) {
|
||||||
core.info(`Running on a ${env.GITHUB_EVENT_NAME || 'push'} event...`)
|
core.info(`Running on a ${github.context.eventName || 'push'} event...`)
|
||||||
diffResult = await getSHAForPushEvent(
|
diffResult = await getSHAForPushEvent(
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
env,
|
||||||
@ -89,8 +90,8 @@ const getChangedFilesFromLocalGit = async ({
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
`Running on a ${env.GITHUB_EVENT_NAME || 'pull_request'} (${
|
`Running on a ${github.context.eventName || 'pull_request'} (${
|
||||||
env.GITHUB_EVENT_ACTION
|
github.context.payload.action
|
||||||
}) event...`
|
}) event...`
|
||||||
)
|
)
|
||||||
diffResult = await getSHAForPullRequestEvent(
|
diffResult = await getSHAForPullRequestEvent(
|
||||||
@ -192,20 +193,17 @@ const getChangedFilesFromLocalGit = async ({
|
|||||||
|
|
||||||
const getChangedFilesFromRESTAPI = async ({
|
const getChangedFilesFromRESTAPI = async ({
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
}: {
|
}: {
|
||||||
inputs: Inputs
|
inputs: Inputs
|
||||||
env: Env
|
|
||||||
workingDirectory: string
|
workingDirectory: string
|
||||||
filePatterns: string[]
|
filePatterns: string[]
|
||||||
yamlFilePatterns: Record<string, string[]>
|
yamlFilePatterns: Record<string, string[]>
|
||||||
}): Promise<void> => {
|
}): Promise<void> => {
|
||||||
const allDiffFiles = await getChangedFilesFromGithubAPI({
|
const allDiffFiles = await getChangedFilesFromGithubAPI({
|
||||||
inputs,
|
inputs
|
||||||
env
|
|
||||||
})
|
})
|
||||||
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
core.debug(`All diff files: ${JSON.stringify(allDiffFiles)}`)
|
||||||
core.info('All Done!')
|
core.info('All Done!')
|
||||||
@ -258,6 +256,9 @@ export async function run(): Promise<void> {
|
|||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
||||||
|
|
||||||
|
const githubContext = github.context
|
||||||
|
core.debug(`Github Context: ${JSON.stringify(githubContext, null, 2)}`)
|
||||||
|
|
||||||
const workingDirectory = path.resolve(
|
const workingDirectory = path.resolve(
|
||||||
env.GITHUB_WORKSPACE || process.cwd(),
|
env.GITHUB_WORKSPACE || process.cwd(),
|
||||||
inputs.path
|
inputs.path
|
||||||
@ -281,7 +282,7 @@ export async function run(): Promise<void> {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
inputs.token &&
|
inputs.token &&
|
||||||
env.GITHUB_EVENT_PULL_REQUEST_NUMBER &&
|
github.context.payload.pull_request?.number &&
|
||||||
!hasGitDirectory
|
!hasGitDirectory
|
||||||
) {
|
) {
|
||||||
core.info("Using GitHub's REST API to get changed files")
|
core.info("Using GitHub's REST API to get changed files")
|
||||||
@ -305,7 +306,6 @@ export async function run(): Promise<void> {
|
|||||||
}
|
}
|
||||||
await getChangedFilesFromRESTAPI({
|
await getChangedFilesFromRESTAPI({
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
filePatterns,
|
filePatterns,
|
||||||
yamlFilePatterns
|
yamlFilePatterns
|
||||||
|
Loading…
x
Reference in New Issue
Block a user