Skip to content

Commit 827dd28

Browse files
committed
fix(renovate): close workflow race windows
1 parent 6445e21 commit 827dd28

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

‎.github/workflows/renovate-bun-nix.yaml‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ jobs:
5252
error make {msg: $"Could not read the pull request: ($response.stderr | str trim)"}
5353
}
5454
let pr = ($response.stdout | from json)
55+
if $pr.state != 'open' {
56+
error make {msg: 'Only open pull requests are allowed'}
57+
}
5558
if $pr.user.login != 'renovate[bot]' {
5659
error make {msg: 'Only pull requests opened by renovate[bot] are allowed'}
5760
}
@@ -121,13 +124,18 @@ jobs:
121124
}
122125
print --stderr ($generation.stdout | str trim)
123126
124-
let changed = (^git diff --name-only | lines | where {|path| not ($path | is-empty)})
127+
let status = (^git status --porcelain=v1 --untracked-files=all | lines | where {|line| not ($line | is-empty)})
128+
let changed = ($status | each {|line| $line | str substring 3..})
125129
let unexpected = ($changed | where {|path| $path !~ '^nix/tools/[^/]+/bun[.]nix$'})
126130
if not ($unexpected | is-empty) {
127131
error make {msg: $"The trusted generator changed unexpected files: ($unexpected | str join ', ')"}
128132
}
129133
130-
let patch = (^git diff --binary --full-index -- 'nix/tools/*/bun.nix' | complete)
134+
let stage = (^git add -- ':(glob)nix/tools/*/bun.nix' | complete)
135+
if $stage.exit_code != 0 {
136+
error make {msg: $"Could not stage the generated Bun derivations: ($stage.stderr | str trim)"}
137+
}
138+
let patch = (^git diff --cached --binary --full-index -- ':(glob)nix/tools/*/bun.nix' | complete)
131139
if $patch.exit_code != 0 {
132140
error make {msg: $"Could not create the Bun derivation patch: ($patch.stderr | str trim)"}
133141
}
@@ -207,7 +215,8 @@ jobs:
207215
if $commit.exit_code != 0 {
208216
error make {msg: $"Could not commit generated Bun derivations: ($commit.stderr | str trim)"}
209217
}
210-
let push = (^git push origin $"HEAD:refs/heads/($env.HEAD_REF)" | complete)
218+
let lease = $"--force-with-lease=refs/heads/($env.HEAD_REF):($env.EXPECTED_HEAD_SHA)"
219+
let push = (^git push $lease origin $"HEAD:refs/heads/($env.HEAD_REF)" | complete)
211220
if $push.exit_code != 0 {
212221
error make {msg: $"Could not push generated Bun derivations: ($push.stderr | str trim)"}
213222
}

0 commit comments

Comments
 (0)