Skip to content

Commit 70491db

Browse files
committed
Handle pre-existing bump branch in stable publish
When release/bump-v<ver> already exists from a prior run, query its actual tip and pass it as expectedHeadOid. Fixes STALE_DATA from createCommitOnBranch after a partial retry.
1 parent 84e5c01 commit 70491db

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

.github/workflows/ci-stable.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,15 @@ jobs:
146146
method="POST",
147147
body={"ref": f"refs/heads/{branch}", "sha": head_oid},
148148
)
149+
expected_oid = head_oid
149150
except urllib.error.HTTPError as error:
150151
if error.code != 422: # 422 = ref already exists; OK to reuse
151152
raise
153+
# Branch already exists (likely from a previous run); use its
154+
# actual tip as expectedHeadOid so createCommitOnBranch doesn't
155+
# fail with STALE_DATA.
156+
ref_info = api(f"repos/{repo}/git/ref/heads/{branch}")
157+
expected_oid = ref_info["object"]["sha"]
152158
153159
def b64(path: str) -> str:
154160
with open(path, "rb") as fp:
@@ -173,7 +179,7 @@ jobs:
173179
"message": {
174180
"headline": f"Bump version to v{version} [skip ci]",
175181
},
176-
"expectedHeadOid": head_oid,
182+
"expectedHeadOid": expected_oid,
177183
"fileChanges": {
178184
"additions": [
179185
{"path": "stable.toml", "contents": b64("stable.toml")},

0 commit comments

Comments
 (0)