Skip to content

Commit

Permalink
fix: update previos sha for forks (#2011)
Browse files Browse the repository at this point in the history
Co-authored-by: GitHub Action <[email protected]>
  • Loading branch information
jackton1 and actions-user authored Mar 26, 2024
1 parent 6354e6c commit f0e7702
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
7 changes: 4 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/commitSha.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ interface SHAForPullRequestEvent {
hasSubmodule: boolean
gitFetchExtraArgs: string[]
remoteName: string
isFork: boolean
}

export const getSHAForPullRequestEvent = async ({
Expand All @@ -334,7 +335,8 @@ export const getSHAForPullRequestEvent = async ({
isShallow,
hasSubmodule,
gitFetchExtraArgs,
remoteName
remoteName,
isFork
}: SHAForPullRequestEvent): Promise<DiffResult> => {
let targetBranch = github.context.payload.pull_request?.base?.ref
const currentBranch = github.context.payload.pull_request?.head?.ref
Expand Down Expand Up @@ -505,7 +507,7 @@ export const getSHAForPullRequestEvent = async ({
}
}
} else {
if (github.context.payload.action === 'closed') {
if (github.context.payload.action === 'closed' || isFork) {
previousSha = github.context.payload.pull_request?.base?.sha
} else {
previousSha = await getRemoteBranchHeadSha({
Expand Down
3 changes: 2 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ const getChangedFilesFromLocalGitHistory = async ({
isShallow,
hasSubmodule,
gitFetchExtraArgs,
remoteName
remoteName,
isFork
})
}

Expand Down

0 comments on commit f0e7702

Please sign in to comment.