Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow_run as eventName #153

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
15 changes: 8 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17928,7 +17928,7 @@ const main = async () => {
} else if (eventName === 'push') {
options.commit = payload.after;
options.head = context.ref;
} else if (eventName === 'workflow_dispatch') {
} else if (eventName === 'workflow_dispatch' || eventName === 'workflow_run') {
options.commit = context.sha;
options.head = context.ref;
}
Expand All @@ -17937,7 +17937,7 @@ const main = async () => {
const changedFiles = await getChangedFiles(options, issueNumberInput);
options.changedFiles = changedFiles;

// when github event is different from `pull_request`, `workflow_dispatch` or `push`
// when github event is different from `pull_request`, `workflow_dispatch`, `workflow_run` or `push`
if (!changedFiles) {
options.reportOnlyChangedFiles = false;
}
Expand Down Expand Up @@ -17983,7 +17983,7 @@ const main = async () => {
if (
!options.hideReport &&
html.length + summaryReport.length > MAX_COMMENT_LENGTH &&
eventName != 'workflow_dispatch'
(eventName != 'workflow_dispatch' && eventName != 'workflow_run')
) {
// generate new html without report
// prettier-ignore
Expand Down Expand Up @@ -18067,7 +18067,7 @@ const main = async () => {
WATERMARK,
);
}
} else if (eventName === 'workflow_dispatch') {
} else if (eventName === 'workflow_dispatch' || eventName === 'workflow_run') {
await core.summary.addRaw(body, true).write();
if (!issueNumberInput) {
// prettier-ignore
Expand Down Expand Up @@ -18095,7 +18095,7 @@ const main = async () => {
} else {
if (!options.hideComment) {
// prettier-ignore
core.warning(`This action supports comments only on \`pull_request\`, \`pull_request_target\`, \`push\` and \`workflow_dispatch\` events. \`${eventName}\` events are not supported.\nYou can use the output of the action.`)
core.warning(`This action supports comments only on \`pull_request\`, \`pull_request_target\`, \`push\`, \`workflow_run\` and \`workflow_dispatch\` events. \`${eventName}\` events are not supported.\nYou can use the output of the action.`)
}
}
};
Expand All @@ -18121,6 +18121,7 @@ const getChangedFiles = async (options, pr_number) => {
base = payload.before;
head = payload.after;
break;
case 'workflow_run':
case 'workflow_dispatch': {
const { data } = await octokit.pulls.get({
owner,
Expand All @@ -18134,7 +18135,7 @@ const getChangedFiles = async (options, pr_number) => {
}
default:
// prettier-ignore
core.warning(`\`report-only-changed-files: true\` supports only on \`pull_request\`, \`workflow_dispatch\` and \`push\`. Other \`${eventName}\` events are not supported.`)
core.warning(`\`report-only-changed-files: true\` supports only on \`pull_request\`, \`workflow_run\`, \`workflow_dispatch\` and \`push\`. Other \`${eventName}\` events are not supported.`)
return null;
}

Expand Down Expand Up @@ -18165,7 +18166,7 @@ const getChangedFiles = async (options, pr_number) => {
if (response.status !== 200) {
core.setFailed(
`The GitHub API for comparing the base and head commits for this ${eventName} event returned ${response.status}, expected 200. ` +
"Please submit an issue on this action's GitHub repo.",
"Please submit an issue on this action's GitHub repo.",
);
}

Expand Down
20 changes: 14 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ const main = async () => {
} else if (eventName === 'push') {
options.commit = payload.after;
options.head = context.ref;
} else if (eventName === 'workflow_dispatch') {
} else if (
eventName === 'workflow_dispatch' ||
eventName === 'workflow_run'
) {
options.commit = context.sha;
options.head = context.ref;
}
Expand All @@ -134,7 +137,7 @@ const main = async () => {
const changedFiles = await getChangedFiles(options, issueNumberInput);
options.changedFiles = changedFiles;

// when github event is different from `pull_request`, `workflow_dispatch` or `push`
// when github event is different from `pull_request`, `workflow_dispatch`, `workflow_run` or `push`
if (!changedFiles) {
options.reportOnlyChangedFiles = false;
}
Expand Down Expand Up @@ -180,7 +183,8 @@ const main = async () => {
if (
!options.hideReport &&
html.length + summaryReport.length > MAX_COMMENT_LENGTH &&
eventName != 'workflow_dispatch'
eventName != 'workflow_dispatch' &&
eventName != 'workflow_run'
) {
// generate new html without report
// prettier-ignore
Expand Down Expand Up @@ -264,7 +268,10 @@ const main = async () => {
WATERMARK,
);
}
} else if (eventName === 'workflow_dispatch') {
} else if (
eventName === 'workflow_dispatch' ||
eventName === 'workflow_run'
) {
await core.summary.addRaw(body, true).write();
if (!issueNumberInput) {
// prettier-ignore
Expand Down Expand Up @@ -292,7 +299,7 @@ const main = async () => {
} else {
if (!options.hideComment) {
// prettier-ignore
core.warning(`This action supports comments only on \`pull_request\`, \`pull_request_target\`, \`push\` and \`workflow_dispatch\` events. \`${eventName}\` events are not supported.\nYou can use the output of the action.`)
core.warning(`This action supports comments only on \`pull_request\`, \`pull_request_target\`, \`push\`, \`workflow_run\` and \`workflow_dispatch\` events. \`${eventName}\` events are not supported.\nYou can use the output of the action.`)
}
}
};
Expand All @@ -318,6 +325,7 @@ const getChangedFiles = async (options, pr_number) => {
base = payload.before;
head = payload.after;
break;
case 'workflow_run':
case 'workflow_dispatch': {
const { data } = await octokit.pulls.get({
owner,
Expand All @@ -331,7 +339,7 @@ const getChangedFiles = async (options, pr_number) => {
}
default:
// prettier-ignore
core.warning(`\`report-only-changed-files: true\` supports only on \`pull_request\`, \`workflow_dispatch\` and \`push\`. Other \`${eventName}\` events are not supported.`)
core.warning(`\`report-only-changed-files: true\` supports only on \`pull_request\`, \`workflow_run\`, \`workflow_dispatch\` and \`push\`. Other \`${eventName}\` events are not supported.`)
return null;
}

Expand Down
Loading