Add "changes" output variable to support matrix job configuration

This commit is contained in:
Michal Dorner 2020-12-17 22:33:11 +01:00
parent 84e1697bff
commit 9e8c9af501
No known key found for this signature in database
GPG key ID: 9EEE04B48DA36786
5 changed files with 67 additions and 4 deletions

View file

@ -175,10 +175,12 @@ async function getChangedFilesFromApi(
function exportResults(results: FilterResults, format: ExportFormat): void {
core.info('Results:')
const changes = []
for (const [key, files] of Object.entries(results)) {
const value = files.length > 0
core.startGroup(`Filter ${key} = ${value}`)
if (files.length > 0) {
changes.push(key)
core.info('Matching files:')
for (const file of files) {
core.info(`${file.filename} [${file.status}]`)
@ -193,6 +195,14 @@ function exportResults(results: FilterResults, format: ExportFormat): void {
core.setOutput(`${key}_files`, filesValue)
}
}
if (results['changes'] === undefined) {
const changesJson = JSON.stringify(changes)
core.info(`Changes output set to ${changesJson}`)
core.setOutput('changes', changesJson)
} else {
core.info('Cannot set changes output variable - name already used by filter output')
}
core.endGroup()
}