@@ -30023,6 +30023,7 @@ function execGit(args) {
3002330023 const debugOutput = [];
3002430024 const warningOutput = [];
3002530025 const errorOutput = [];
30026+ core.debug('execGit() - args: ' + JSON.stringify(args));
3002630027 yield (0, exec_1.exec)('git', args, {
3002730028 silent: true,
3002830029 ignoreReturnCode: true,
@@ -30067,8 +30068,15 @@ function pushCurrentBranch() {
3006730068}
3006830069function addFileChanges(globPatterns) {
3006930070 return __awaiter(this, void 0, void 0, function* () {
30071+ const cwd = (0, cwd_1.getCwd)();
3007030072 const workspace = (0, cwd_1.getWorkspace)();
30071- const workspacePaths = globPatterns.map((p) => (0, node_path_1.join)(workspace, p));
30073+ const resolvedWorkspace = (0, node_path_1.resolve)(workspace);
30074+ core.debug('addFileChanges() - resolvedWorkspace: ' + JSON.stringify(resolvedWorkspace));
30075+ let workspacePaths = globPatterns;
30076+ if (resolvedWorkspace.includes(cwd)) {
30077+ core.notice('addFileChanges() - "workspace" is a subdirectory, updating globPatterns');
30078+ workspacePaths = globPatterns.map((p) => (0, node_path_1.join)((0, node_path_1.relative)(cwd, resolvedWorkspace), p));
30079+ }
3007230080 yield execGit(['add', '--', ...workspacePaths]);
3007330081 });
3007430082}
@@ -30445,52 +30453,68 @@ const core = __importStar(__nccwpck_require__(7484));
3044530453const graphql_1 = __nccwpck_require__(1422);
3044630454const repo_1 = __nccwpck_require__(1839);
3044730455const git_1 = __nccwpck_require__(1243);
30456+ const cwd_1 = __nccwpck_require__(9827);
3044830457const input_1 = __nccwpck_require__(7797);
3044930458const errors_1 = __nccwpck_require__(3916);
3045030459function run() {
3045130460 return __awaiter(this, void 0, void 0, function* () {
3045230461 var _a, _b, _c, _d, _e, _f;
3045330462 try {
30463+ core.info('Getting info from GH Worklfow context');
3045430464 const { owner, repo, branch } = (0, repo_1.getContext)();
30455- const inputRepository = (0, input_1.getInput)('repository');
30465+ core.info('Setting variables according to inputs and context');
30466+ core.debug('* branch');
3045630467 const inputBranch = (0, input_1.getInput)('branch-name');
30457- if (inputBranch && inputBranch !== branch) {
30458- yield (0, git_1.switchBranch)(inputBranch);
30468+ const selectedBranch = inputBranch ? inputBranch : branch;
30469+ core.debug('* owner');
30470+ const inputOwner = (0, input_1.getInput)('owner');
30471+ const selectedOwner = inputOwner ? inputOwner : owner;
30472+ core.debug('* repo');
30473+ const inputRepo = (0, input_1.getInput)('repo');
30474+ const selectedRepo = inputRepo ? inputRepo : repo;
30475+ if (selectedOwner == owner &&
30476+ selectedRepo == repo &&
30477+ selectedBranch !== branch) {
30478+ core.warning('Pushing local and current branch to remote before proceeding');
30479+ // Git commands
30480+ yield (0, git_1.switchBranch)(selectedBranch);
3045930481 yield (0, git_1.pushCurrentBranch)();
3046030482 }
30461- const repositoryParts = inputRepository ? inputRepository.split('/') : [];
30462- if (repositoryParts.length && repositoryParts.length != 2) {
30463- throw new errors_1.InputRepositoryInvalid(inputRepository);
30464- }
30465- const currentOwner = repositoryParts.length ? repositoryParts[0] : owner;
30466- const currentRepository = repositoryParts.length ? repositoryParts[1] : repo;
30467- const currentBranch = inputBranch ? inputBranch : branch;
30468- const repository = yield core.group(`fetching repository info for owner: ${currentOwner}, repo: ${currentRepository}, branch: ${currentBranch}`, () => __awaiter(this, void 0, void 0, function* () {
30483+ const repository = yield core.group(`fetching repository info for owner: ${selectedOwner}, repo: ${selectedRepo}, branch: ${selectedBranch}`, () => __awaiter(this, void 0, void 0, function* () {
3046930484 const startTime = Date.now();
30470- const repositoryData = yield (0, graphql_1.getRepository)(currentOwner, currentRepository, currentBranch );
30485+ const repositoryData = yield (0, graphql_1.getRepository)(selectedOwner, selectedRepo, selectedBranch );
3047130486 const endTime = Date.now();
3047230487 core.debug(`time taken: ${(endTime - startTime).toString()} ms`);
3047330488 return repositoryData;
3047430489 }));
30490+ core.info('Checking remote branches');
3047530491 if (!repository.ref) {
30476- if (inputBranch && currentBranch == inputBranch ) {
30492+ if (inputBranch) {
3047730493 throw new errors_1.InputBranchNotFound(inputBranch);
3047830494 }
3047930495 else {
30480- throw new errors_1.BranchNotFound(currentBranch );
30496+ throw new errors_1.BranchNotFound(branch );
3048130497 }
3048230498 }
30499+ core.info('Processing to create signed commit');
30500+ core.debug('Get last (current?) commit');
3048330501 const currentCommit = (_b = (_a = repository.ref.target.history) === null || _a === void 0 ? void 0 : _a.nodes) === null || _b === void 0 ? void 0 : _b[0];
3048430502 if (!currentCommit) {
3048530503 throw new errors_1.BranchCommitNotFound(repository.ref.name);
3048630504 }
3048730505 let createdCommit;
3048830506 const filePaths = core.getMultilineInput('files');
3048930507 if (filePaths.length <= 0) {
30490- core.debug ('skip file commit, empty files input');
30508+ core.notice ('skip file commit, empty files input');
3049130509 }
3049230510 else {
30493- core.debug(`proceed with file commit, input: ${JSON.stringify(filePaths)}`);
30511+ core.debug(`Proceed with file commit, input: ${JSON.stringify(filePaths)}`);
30512+ const workdir = (0, cwd_1.getWorkdir)();
30513+ const cwd = (0, cwd_1.getCwd)();
30514+ if (cwd !== workdir) {
30515+ core.notice('Changing working directory to Workdir: ' + workdir);
30516+ process.chdir(workdir);
30517+ }
3049430518 yield (0, git_1.addFileChanges)(filePaths);
3049530519 const fileChanges = yield (0, git_1.getFileChanges)();
3049630520 const fileCount = ((_d = (_c = fileChanges.additions) === null || _c === void 0 ? void 0 : _c.length) !== null && _d !== void 0 ? _d : 0) +
@@ -30512,7 +30536,7 @@ function run() {
3051230536 const startTime = Date.now();
3051330537 const commitData = yield (0, graphql_1.createCommitOnBranch)(currentCommit, commitMessage, {
3051430538 repositoryNameWithOwner: repository.nameWithOwner,
30515- branchName: currentBranch ,
30539+ branchName: selectedBranch ,
3051630540 }, fileChanges);
3051730541 const endTime = Date.now();
3051830542 core.debug(`time taken: ${(endTime - startTime).toString()} ms`);
@@ -30646,6 +30670,7 @@ var __importStar = (this && this.__importStar) || (function () {
3064630670Object.defineProperty(exports, "__esModule", ({ value: true }));
3064730671exports.getCwd = getCwd;
3064830672exports.getWorkspace = getWorkspace;
30673+ exports.getWorkdir = getWorkdir;
3064930674const core = __importStar(__nccwpck_require__(7484));
3065030675const input_1 = __nccwpck_require__(7797);
3065130676function getCwd() {
@@ -30660,6 +30685,13 @@ function getWorkspace() {
3066030685 core.debug(`workspace: ${workspace}`);
3066130686 return workspace;
3066230687}
30688+ function getWorkdir() {
30689+ const workdir = (0, input_1.getInput)('workdir', {
30690+ default: process.env.GITHUB_WORKSPACE,
30691+ });
30692+ core.debug(`workdir: ${workdir}`);
30693+ return workdir;
30694+ }
3066330695
3066430696
3066530697/***/ }),
0 commit comments