- improve setting the outputs when loading the pr data from the cache

This commit is contained in:
Mike Penz
2023-07-13 07:59:19 +00:00
committed by GitHub
parent 9f4822781f
commit f556874ff0
6 changed files with 50 additions and 39 deletions
+27 -18
View File
@@ -1,7 +1,7 @@
import * as core from '@actions/core'
import {Configuration} from './configuration'
import {checkExportedData} from './utils'
import {buildChangelog} from './transform'
import {PullRequestData, buildChangelog} from './transform'
import {PullRequestCollector} from 'github-pr-collector'
import {failOrError} from 'github-pr-collector/lib/utils'
import {TagInfo} from 'github-pr-collector/lib/tags'
@@ -48,6 +48,7 @@ export class ReleaseNotesBuilder {
private configuration: Configuration
) {}
async build(): Promise<string | null> {
const releaseNotesData = checkExportedData()
if (releaseNotesData == null) {
@@ -55,7 +56,6 @@ export class ReleaseNotesBuilder {
failOrError(`💥 Missing or couldn't resolve 'owner'`, this.failOnError)
return null
} else {
core.setOutput('owner', this.owner)
core.debug(`Resolved 'owner' as ${this.owner}`)
}
@@ -63,7 +63,6 @@ export class ReleaseNotesBuilder {
failOrError(`💥 Missing or couldn't resolve 'owner'`, this.failOnError)
return null
} else {
core.setOutput('repo', this.repo)
core.debug(`Resolved 'repo' as ${this.repo}`)
}
core.endGroup()
@@ -105,21 +104,7 @@ export class ReleaseNotesBuilder {
}
const mergedPullRequests = prData.mergedPullRequests
const diffInfo = prData.diffInfo
// define the included PRs within this release as output
core.setOutput(
'pull_requests',
mergedPullRequests
.map(pr => {
return pr.number
})
.join(',')
)
core.setOutput('changed_files', diffInfo.changedFiles)
core.setOutput('additions', diffInfo.additions)
core.setOutput('deletions', diffInfo.deletions)
core.setOutput('changes', diffInfo.changes)
core.setOutput('commits', diffInfo.commits)
this.setOutputs(options, diffInfo, mergedPullRequests)
const cache = {
mergedPullRequests,
@@ -168,7 +153,31 @@ export class ReleaseNotesBuilder {
commitMode: this.commitMode || orgOptions.commitMode,
configuration: this.configuration || orgOptions.configuration
}
this.setOutputs(options, diffInfo, mergedPullRequests)
return buildChangelog(diffInfo, mergedPullRequests, options)
}
}
setOutputs(options: ReleaseNotesOptions, diffInfo: DiffInfo, mergedPullRequests: PullRequestData[]): void {
core.setOutput('owner', options.owner)
core.setOutput('repo', options.repo)
core.setOutput('toTag', options.toTag.name)
core.setOutput('fromTag', options.fromTag.name)
// define the included PRs within this release as output
core.setOutput(
'pull_requests',
mergedPullRequests
.map(pr => {
return pr.number
})
.join(',')
)
core.setOutput('changed_files', diffInfo.changedFiles)
core.setOutput('additions', diffInfo.additions)
core.setOutput('deletions', diffInfo.deletions)
core.setOutput('changes', diffInfo.changes)
core.setOutput('commits', diffInfo.commits)
}
}