async function main() {
  await execFile('git', ['add', '.'])
  const diffResultPromise = execFile(
    'git',
    ['diff', '--staged', '-b', '--quiet'],
    { encoding: 'utf8' },
  )

  try {
    await diffResultPromise
    console.log('::notice::No dirty files detected')
  } catch (e) {
    if (e.code !== 1 || e.killed || e.stderr !== '') {
      throw e
    }
    // something changed, and we should fail the build
    process.exitCode = 1

    console.log(
      '::error,title=Dirty File::Working area contains unexpected changes; see job log for diff'
    )
    const { stdout } = await execFile(
      'git',
      ['diff', '--staged', '-b'],
      { encoding: 'utf8' },
    )
    console.log(stdout)
  }
}
Asks `git` if any files changed and exits with a non-zero exit code if so.

@returns {Promise<void>}
@todo We could determine what lines changed in what file so the file would be
  annotated with the error, but it requires some extra parsing of `git diff`
  output.