Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ inputs:
description: 'Set files or directories to exclude from a publish directory.'
required: false
default: '.github'
outputs:
dst_sha:
description: 'Deployed commit hash.'
1 change: 1 addition & 0 deletions lib/index.js

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion src/git-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,32 @@ export function getCommitMessage(
return subject;
}

export async function commit(allowEmptyCommit: boolean, msg: string): Promise<void> {
export async function commit(allowEmptyCommit: boolean, msg: string): Promise<string> {
try {
if (allowEmptyCommit) {
await exec.exec('git', ['commit', '--allow-empty', '-m', `${msg}`]);
} else {
await exec.exec('git', ['commit', '-m', `${msg}`]);
}

const result: CmdResult = {
exitcode: 0,
output: ''
};
const options = {
listeners: {
stdout: (data: Buffer): void => {
result.output += data.toString();
}
}
};
result.exitcode = await exec.exec('git', ['rev-parse', 'HEAD'], options);

return result.output;
} catch (e) {
core.info('[INFO] skip commit');
core.debug(`[INFO] skip commit ${e.message}`);
return '';
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ export async function run(): Promise<void> {
baseRepo,
hash
);
await commit(inps.AllowEmptyCommit, commitMessage);
const dstSHA = await commit(inps.AllowEmptyCommit, commitMessage);
core.setOutput('dst_sha', dstSHA);
core.endGroup();

core.startGroup('Push the commit or tag');
Expand Down