- refactor the caching logic given the GitHub action limit on arguments is too small to allow passing in the whole cache

- adjust the `cache` to now only take the file-path to read the cache from
  - offer temporary backwards compatiblity on passing the cache directly
  - add documentation for cache vars in README
This commit is contained in:
Mike Penz
2023-08-25 08:23:54 +00:00
committed by GitHub
parent fa2cca75cf
commit a72c0bbc47
8 changed files with 152 additions and 30 deletions
+13 -5
View File
@@ -1,12 +1,13 @@
import * as core from '@actions/core'
import {Configuration} from './configuration'
import {checkExportedData} from './utils'
import {checkExportedData, writeCacheData} from './utils'
import {PullRequestData, buildChangelog} from './transform'
import {PullRequestCollector} from './pr-collector/prCollector'
import {failOrError} from './pr-collector/utils'
import {TagInfo} from './pr-collector/tags'
import {DiffInfo} from './pr-collector/commits'
import {PullRequestInfo} from './pr-collector/pullRequests'
import * as fs from 'fs'
export interface ReleaseNotesOptions {
owner: string // the owner of the repository
@@ -47,11 +48,18 @@ export class ReleaseNotesBuilder {
private commitMode = false,
private exportCache = false,
private exportOnly = false,
private cache: string | null = null,
private configuration: Configuration
) {}
async build(): Promise<string | null> {
const releaseNotesData = checkExportedData()
let releaseNotesData: Data | null
try {
releaseNotesData = checkExportedData(this.exportCache, this.cache)
} catch (error) {
failOrError(`${error}`, this.failOnError)
return null
}
if (releaseNotesData == null) {
if (!this.owner) {
failOrError(`💥 Missing or couldn't resolve 'owner'`, this.failOnError)
@@ -109,13 +117,13 @@ export class ReleaseNotesBuilder {
this.setOutputs(options, diffInfo, mergedPullRequests)
if (this.exportCache) {
const cache = {
const cacheData = {
mergedPullRequests,
diffInfo,
options
}
core.setOutput(`cache`, JSON.stringify(cache))
//fs.writeFileSync(path.resolve('cache.json'), JSON.stringify(cache))
writeCacheData(cacheData, this.cache)
if (this.exportOnly) {
core.info(`️ Enabled 'exportOnly' will not generate changelog`)