From 0cce70c45a376da46abbc00c10e071b998bba733 Mon Sep 17 00:00:00 2001 From: Ernane Ferreira Date: Sun, 7 May 2023 17:41:03 -0300 Subject: [PATCH] Solve - bug: manual tasks break data submission #2 (#3) * wip: dealing with a manual workflow * fix: change payload.head_commit.author.name to actor on run manualy * fix: manual tasks break data submission --- dist/index.js | 13 ++++++++----- lib/utils.js | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6da1427..6fab797 100644 --- a/dist/index.js +++ b/dist/index.js @@ -17628,7 +17628,10 @@ function getDiscordPayload(inputs) { const repoURL = `${serverUrl}/${owner}/${repo}`; const workflowURL = `${repoURL}/actions/runs/${runId}`; - const eventDetail = `[${payload.head_commit.author.name}](https://github.com/${actor}) authored & committed - ${payload.head_commit.message}`; + const eventDetail = payload.head_commit ? + `[${payload.head_commit.author.name}](https://github.com/${actor}) authored & committed - ${payload.head_commit.message}` : + `Action manually run by [${actor}](https://github.com/${actor})`; + const [ refs, head, branch ] = ref.split('/'); if(!inputs.status) inputs.status = DEFAULT_VALUES.status; @@ -17662,11 +17665,11 @@ function getDiscordPayload(inputs) { if (inputs.event_info) { embed.fields = [ { name: '', value: '', inline: false }, - { name: 'Repository', value: `[${owner}/${repo}](${repoURL})`, inline: true }, - { name: 'Branch', value: `[${branch}](${repoURL}/tree/${branch})`, inline: true }, + { name: 'Repository', value: `[\`${owner}/${repo}\`](${repoURL})`, inline: true }, + { name: 'Branch', value: `[\`${branch}\`](${repoURL}/tree/${branch})`, inline: true }, { name: '', value: '', inline: false }, - { name: 'Commit', value: `[\`${payload.head_commit.id.substring(0, 7)}\`](${payload.head_commit.url})`, inline: true }, - { name: 'Workflow', value: `[${workflow}#${runId}](${workflowURL})`, inline: true }, + { name: 'Commit', value: payload.head_commit ? `[\`${payload.head_commit.id.substring(0, 7)}\`](${payload.head_commit.url})` : '-', inline: true }, + { name: 'Workflow', value: `[\`${workflow}#${runId}\`](${workflowURL})`, inline: true }, { name: '', value: '', inline: false }, ] } diff --git a/lib/utils.js b/lib/utils.js index 3b77c7a..e5848cc 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -24,7 +24,10 @@ export function getDiscordPayload(inputs) { const repoURL = `${serverUrl}/${owner}/${repo}`; const workflowURL = `${repoURL}/actions/runs/${runId}`; - const eventDetail = `[${payload.head_commit.author.name}](https://github.com/${actor}) authored & committed - ${payload.head_commit.message}`; + const eventDetail = payload.head_commit ? + `[${payload.head_commit.author.name}](https://github.com/${actor}) authored & committed - ${payload.head_commit.message}` : + `Action manually run by [${actor}](https://github.com/${actor})`; + const [ refs, head, branch ] = ref.split('/'); if(!inputs.status) inputs.status = DEFAULT_VALUES.status; @@ -58,11 +61,11 @@ export function getDiscordPayload(inputs) { if (inputs.event_info) { embed.fields = [ { name: '', value: '', inline: false }, - { name: 'Repository', value: `[${owner}/${repo}](${repoURL})`, inline: true }, - { name: 'Branch', value: `[${branch}](${repoURL}/tree/${branch})`, inline: true }, + { name: 'Repository', value: `[\`${owner}/${repo}\`](${repoURL})`, inline: true }, + { name: 'Branch', value: `[\`${branch}\`](${repoURL}/tree/${branch})`, inline: true }, { name: '', value: '', inline: false }, - { name: 'Commit', value: `[\`${payload.head_commit.id.substring(0, 7)}\`](${payload.head_commit.url})`, inline: true }, - { name: 'Workflow', value: `[${workflow}#${runId}](${workflowURL})`, inline: true }, + { name: 'Commit', value: payload.head_commit ? `[\`${payload.head_commit.id.substring(0, 7)}\`](${payload.head_commit.url})` : '-', inline: true }, + { name: 'Workflow', value: `[\`${workflow}#${runId}\`](${workflowURL})`, inline: true }, { name: '', value: '', inline: false }, ] }