File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -202,6 +202,20 @@ export default eventHandler(async (event) => {
202202 } ) ;
203203 }
204204
205+ if (
206+ workflowData . headBranch &&
207+ workflowData . headBranch !== workflowData . ref
208+ ) {
209+ const branchCursorKey = `${ baseKey } :${ workflowData . headBranch } ` ;
210+ const branchCursor = await cursorBucket . getItem ( branchCursorKey ) ;
211+ if ( ! branchCursor || branchCursor . timestamp < runId ) {
212+ await cursorBucket . setItem ( branchCursorKey , {
213+ sha : workflowData . sha ,
214+ timestamp : runId ,
215+ } ) ;
216+ }
217+ }
218+
205219 await workflowsBucket . removeItem ( key ) ;
206220
207221 const urls = packagesWithoutPrefix . map ( ( packageName ) =>
Original file line number Diff line number Diff line change @@ -55,11 +55,18 @@ export default eventHandler(async (event) => {
5555 const lookupKey = isNewPullRequest ? prKey : oldPrDataHash ;
5656 const prNumber = await pullRequestNumbersBucket . getItem ( lookupKey ) ;
5757
58+ const headBranch = payload . workflow_run . head_branch ;
59+ const isHeadOnUpstream =
60+ payload . workflow_run . head_repository ?. full_name ===
61+ payload . repository . full_name ;
62+
5863 const data : WorkflowData = {
5964 owner,
6065 repo,
6166 sha : payload . workflow_run . head_sha ,
62- ref : isPullRequest ? `${ prNumber } ` : payload . workflow_run . head_branch ! , // it's a pull request workflow
67+ ref : isPullRequest ? `${ prNumber } ` : headBranch ! ,
68+ headBranch :
69+ isPullRequest && isHeadOnUpstream && headBranch ? headBranch : null ,
6370 } ;
6471
6572 // Publishing is only available throughout the lifetime of a workflow_job
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ export interface WorkflowData {
33 repo : string ;
44 sha : string ;
55 ref : string ;
6+ headBranch ?: string | null ;
67}
78
89export interface PullRequestData {
You can’t perform that action at this time.
0 commit comments