mirror of
https://github.com/tj-actions/changed-files
synced 2025-01-30 19:30:19 +00:00
feat: add support to detect changes for merge group event (#1404)
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
fc3c551a67
commit
b8e577a274
4 changed files with 16 additions and 9 deletions
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
|
@ -57,6 +57,8 @@ const getCurrentSHA = async ({
|
||||||
})) === 0
|
})) === 0
|
||||||
) {
|
) {
|
||||||
currentSha = github.context.payload.pull_request?.head?.sha
|
currentSha = github.context.payload.pull_request?.head?.sha
|
||||||
|
} else if (github.context.eventName === 'merge_group') {
|
||||||
|
currentSha = github.context.payload.merge_group?.head_sha
|
||||||
} else {
|
} else {
|
||||||
currentSha = await getHeadSha({cwd: workingDirectory})
|
currentSha = await getHeadSha({cwd: workingDirectory})
|
||||||
}
|
}
|
||||||
|
@ -78,7 +80,7 @@ export interface DiffResult {
|
||||||
initialCommit?: boolean
|
initialCommit?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getSHAForPushEvent = async (
|
export const getSHAForNonPullRequestEvent = async (
|
||||||
inputs: Inputs,
|
inputs: Inputs,
|
||||||
env: Env,
|
env: Env,
|
||||||
workingDirectory: string,
|
workingDirectory: string,
|
||||||
|
@ -197,12 +199,17 @@ export const getSHAForPushEvent = async (
|
||||||
previousSha = sha
|
previousSha = sha
|
||||||
targetBranch = tag
|
targetBranch = tag
|
||||||
} else {
|
} else {
|
||||||
core.debug('Getting previous SHA for last remote commit...')
|
if (github.context.eventName === 'merge_group') {
|
||||||
if (
|
core.debug('Getting previous SHA for merge group...')
|
||||||
github.context.payload.forced === 'false' ||
|
previousSha = github.context.payload.merge_group?.base_sha
|
||||||
!github.context.payload.forced
|
} else {
|
||||||
) {
|
core.debug('Getting previous SHA for last remote commit...')
|
||||||
previousSha = github.context.payload.before
|
if (
|
||||||
|
github.context.payload.forced === 'false' ||
|
||||||
|
!github.context.payload.forced
|
||||||
|
) {
|
||||||
|
previousSha = github.context.payload.before
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
|
|
|
@ -12,7 +12,7 @@ import {setChangedFilesOutput} from './changedFilesOutput'
|
||||||
import {
|
import {
|
||||||
DiffResult,
|
DiffResult,
|
||||||
getSHAForPullRequestEvent,
|
getSHAForPullRequestEvent,
|
||||||
getSHAForPushEvent
|
getSHAForNonPullRequestEvent
|
||||||
} from './commitSha'
|
} from './commitSha'
|
||||||
import {Env, getEnv} from './env'
|
import {Env, getEnv} from './env'
|
||||||
import {getInputs, Inputs} from './inputs'
|
import {getInputs, Inputs} from './inputs'
|
||||||
|
@ -130,7 +130,7 @@ const getChangedFilesFromLocalGit = async ({
|
||||||
|
|
||||||
if (!github.context.payload.pull_request?.base?.ref) {
|
if (!github.context.payload.pull_request?.base?.ref) {
|
||||||
core.info(`Running on a ${github.context.eventName || 'push'} event...`)
|
core.info(`Running on a ${github.context.eventName || 'push'} event...`)
|
||||||
diffResult = await getSHAForPushEvent(
|
diffResult = await getSHAForNonPullRequestEvent(
|
||||||
inputs,
|
inputs,
|
||||||
env,
|
env,
|
||||||
workingDirectory,
|
workingDirectory,
|
||||||
|
|
Loading…
Reference in a new issue