Support push event (#10)

* Support triggering from push event
* Add self-test to build workflow
* Update action metadata
This commit is contained in:
Michal Dorner 2020-06-15 21:49:10 +02:00 committed by GitHub
parent 910e8b1235
commit affb29871a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 89 additions and 61 deletions

View file

@ -1,22 +1,22 @@
import {exec} from '@actions/exec'
export async function fetchBranch(base: string): Promise<void> {
const exitCode = await exec('git', ['fetch', '--depth=1', 'origin', base])
export async function fetchCommit(sha: string): Promise<void> {
const exitCode = await exec('git', ['fetch', '--depth=1', 'origin', sha])
if (exitCode !== 0) {
throw new Error(`Fetching branch ${base} failed, exiting`)
throw new Error(`Fetching commit ${sha} failed`)
}
}
export async function getChangedFiles(base: string): Promise<string[]> {
export async function getChangedFiles(sha: string): Promise<string[]> {
let output = ''
const exitCode = await exec('git', ['diff-index', '--name-only', base], {
const exitCode = await exec('git', ['diff-index', '--name-only', sha], {
listeners: {
stdout: (data: Buffer) => (output += data.toString())
}
})
if (exitCode !== 0) {
throw new Error(`Couldn't determine changed files, exiting`)
throw new Error(`Couldn't determine changed files`)
}
return output