2019-12-03 16:28:59 +01:00
|
|
|
import * as core from '@actions/core'
|
|
|
|
import * as coreCommand from '@actions/core/lib/command'
|
|
|
|
import * as gitSourceProvider from './git-source-provider'
|
|
|
|
import * as inputHelper from './input-helper'
|
|
|
|
import * as path from 'path'
|
2019-12-12 19:16:16 +01:00
|
|
|
import * as stateHelper from './state-helper'
|
2019-12-03 16:28:59 +01:00
|
|
|
|
|
|
|
async function run(): Promise<void> {
|
|
|
|
try {
|
|
|
|
const sourceSettings = inputHelper.getInputs()
|
|
|
|
|
|
|
|
try {
|
|
|
|
// Register problem matcher
|
|
|
|
coreCommand.issueCommand(
|
|
|
|
'add-matcher',
|
|
|
|
{},
|
|
|
|
path.join(__dirname, 'problem-matcher.json')
|
|
|
|
)
|
|
|
|
|
|
|
|
// Get sources
|
|
|
|
await gitSourceProvider.getSource(sourceSettings)
|
|
|
|
} finally {
|
|
|
|
// Unregister problem matcher
|
|
|
|
coreCommand.issueCommand('remove-matcher', {owner: 'checkout-git'}, '')
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
core.setFailed(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async function cleanup(): Promise<void> {
|
|
|
|
try {
|
2019-12-12 19:16:16 +01:00
|
|
|
await gitSourceProvider.cleanup(stateHelper.RepositoryPath)
|
2019-12-03 16:28:59 +01:00
|
|
|
} catch (error) {
|
|
|
|
core.warning(error.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Main
|
2019-12-12 19:16:16 +01:00
|
|
|
if (!stateHelper.IsPost) {
|
2019-12-03 16:28:59 +01:00
|
|
|
run()
|
|
|
|
}
|
|
|
|
// Post
|
|
|
|
else {
|
|
|
|
cleanup()
|
|
|
|
}
|