Skip to content

Don't request the API if author_name and author_email are set #126

Description

@ocean90

I might be missing something but I think there's no need to request the GitHub API if both author_name and author_email inputs are set?

add-and-commit/src/main.ts

Lines 229 to 258 in 941a2d6

// #region author_name, author_email
let author = event?.head_commit?.author
if (sha && !author) {
info(
'> Unable to get commit from workflow event: trying with the GitHub API...'
)
// https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples
const url = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}`,
headers = token
? {
Authorization: `Bearer ${token}`
}
: undefined,
commit = (
await axios.get(url, { headers }).catch((err) => {
startGroup('Request error:')
info(`> Request URL: ${url}\b${err}`)
endGroup()
return undefined
})
)?.data
author = commit?.commit?.author
}
if (author) {
setDefault('author_name', author.name)
setDefault('author_email', author.email)
}

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions