Skip to content

Commit

Permalink
Use workflow_run.repository.html_url instead of handcoding it
Browse files Browse the repository at this point in the history
Also should fix an issue with GitHub Enterprise urls
  • Loading branch information
ojab authored and AnthonyKinson committed Nov 24, 2021
1 parent ea2df14 commit 1394f29
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9415,16 +9415,16 @@ function main() {
start: new Date(workflow_run.created_at),
end: new Date(workflow_run.updated_at)
});
const repo_url = `<https://github.com/${workflow_run.repository.full_name}|*${workflow_run.repository.full_name}*>`;
const branch_url = `<https://github.com/${workflow_run.repository.full_name}/tree/${workflow_run.head_branch}|*${workflow_run.head_branch}*>`;
const repo_url = `<${workflow_run.repository.html_url}|*${workflow_run.repository.full_name}*>`;
const branch_url = `<${workflow_run.repository.html_url}/tree/${workflow_run.head_branch}|*${workflow_run.head_branch}*>`;
const workflow_run_url = `<${workflow_run.html_url}|#${workflow_run.run_number}>`;
// Example: Success: AnthonyKinson's `push` on `master` for pull_request
let status_string = `${workflow_msg} ${github_1.context.actor}'s \`${github_1.context.eventName}\` on \`${branch_url}\`\n`;
// Example: Workflow: My Workflow #14 completed in `1m 30s`
const details_string = `Workflow: ${github_1.context.workflow} ${workflow_run_url} completed in \`${workflow_duration}\``;
// Build Pull Request string if required
const pull_requests = workflow_run.pull_requests
.map(pull_request => `<https://github.com/${workflow_run.repository.full_name}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``)
.map(pull_request => `<${workflow_run.repository.html_url}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``)
.join(', ');
if (pull_requests !== '') {
status_string = `${workflow_msg} ${github_1.context.actor}'s \`pull_request\` ${pull_requests}\n`;
Expand Down
6 changes: 3 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ async function main(): Promise<void> {
start: new Date(workflow_run.created_at),
end: new Date(workflow_run.updated_at)
})
const repo_url = `<https://github.com/${workflow_run.repository.full_name}|*${workflow_run.repository.full_name}*>`
const branch_url = `<https://github.com/${workflow_run.repository.full_name}/tree/${workflow_run.head_branch}|*${workflow_run.head_branch}*>`
const repo_url = `<${workflow_run.repository.html_url}|*${workflow_run.repository.full_name}*>`
const branch_url = `<${workflow_run.repository.html_url}/tree/${workflow_run.head_branch}|*${workflow_run.head_branch}*>`
const workflow_run_url = `<${workflow_run.html_url}|#${workflow_run.run_number}>`
// Example: Success: AnthonyKinson's `push` on `master` for pull_request
let status_string = `${workflow_msg} ${context.actor}'s \`${context.eventName}\` on \`${branch_url}\`\n`
Expand All @@ -161,7 +161,7 @@ async function main(): Promise<void> {
const pull_requests = (workflow_run.pull_requests as PullRequest[])
.map(
pull_request =>
`<https://github.com/${workflow_run.repository.full_name}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``
`<${workflow_run.repository.html_url}/pull/${pull_request.number}|#${pull_request.number}> from \`${pull_request.head.ref}\` to \`${pull_request.base.ref}\``
)
.join(', ')

Expand Down

0 comments on commit 1394f29

Please sign in to comment.