Skip to content

Commit

Permalink
return repsonse data, then map to latest tag
Browse files Browse the repository at this point in the history
  • Loading branch information
craig-day committed Mar 24, 2021
1 parent e5a5c89 commit 61cd98e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions action.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ async function existingTags() {

return await octokit
.paginate(options)
.then((refs) => refs.reverse())
.then((refs) => {
core.info('Tags fetch complete.')
return refs.reverse()
})
.catch((e) => {
core.setFailed(`Failed to fetch matching refs (tags): ${e}`)
})
Expand All @@ -59,19 +62,21 @@ async function latestTagOnBranch(branch, tags) {
sha: branch,
})

let latestTag

return await octokit
.paginate(options, (response, done) => {
let latestTag

response.data.find((commit) => {
latestTag = tags.find((tag) => tag.object.sha === commit.sha)
})

if (latestTag) {
done()
return latestTag
}

return response.data
})
.then((_commits) => latestTag)
.catch((e) => {
core.setFailed(`Failed to fetch commits for branch '${branch}' : ${e}`)
})
Expand Down

0 comments on commit 61cd98e

Please sign in to comment.