Files
superset2/.github/actions/file-changes-action/src/main.ts
Jesse Yang a3bbbf8ea3 build: inline external Github Actions to unblock CI (#12241)
* build: inline cached-dependencies to unblock CI

* Run E2E on pull_request on;y

* Inline all external actions

* Checkout needed for internal actions

Also fixes pre-commit

* Add missing files
2021-01-04 14:16:07 +02:00

41 lines
1.3 KiB
TypeScript

import {setFailed as coreSetFailed} from '@actions/core'
import {getInputs, inferInput} from './InputHelper'
import {writeOutput, writeFiles, sortChangedFiles} from './FilesHelper'
import {getChangedFiles, initClient} from './GithubHelper'
import {errorMessage} from './UtilsHelper'
// figure out if it is a PR or Push
export async function run(): Promise<void> {
try {
// get inputs
const inputs = getInputs()
// parse input
const inferred = inferInput(
inputs.pushBefore,
inputs.pushAfter,
inputs.prNumber
)
// prepare client
const client = initClient(inputs.githubToken)
// get changed files
const changedFilesArray = await getChangedFiles(
client,
inputs.githubRepo,
inferred
)
// sort changed files
const changedFiles = sortChangedFiles(changedFilesArray)
Object.keys(changedFiles).forEach(key => {
// write file output
writeFiles(inputs.fileOutput, key, changedFiles[key])
// write output vars
writeOutput(inputs.output, key, changedFiles[key])
})
} catch (error) {
const pError = JSON.parse(error.message)
coreSetFailed(errorMessage(pError.from, pError))
throw new Error(JSON.stringify(pError))
}
}
/* istanbul ignore next */
if (!(process.env.INPUT_MOCK === 'true')) run()