Skip to content

Commit 0442778

Browse files
fix(ci): carry a composite action's dependencies to the entry the workflow names
The lockfile blocks were restored but Pages still failed in Set up job with the same message. The reason is which entry carries the dependency list: 'actions/upload-pages-artifact@v5.0.0': <- gh actions-lock wrote `uses:` here ... uses: - 'actions/upload-artifact@bbbca2dd…' 'actions/upload-pages-artifact@fc324d35…': <- the workflow names THIS one ref: 'v5.0.0' ... The tag-keyed entry had the `uses:` list; the workflow re-pinned to the SHA, so GitHub resolved the SHA entry, found no dependency list, and refused the job. Restoring the block was necessary and not sufficient. Regeneration now copies the `uses:` list onto every entry describing the same commit, so a re-pin cannot separate an action from the actions it resolves. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
1 parent b22bed4 commit 0442778

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

‎.github/workflows/actions.lock‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ dependencies:
182182
commit: 'sha1-fc324d3547104276b827a68afc52ff2a11cc49c9'
183183
owner_id: 44036562
184184
repo_id: 496012378
185+
uses:
186+
- 'actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f'
185187
'actions/upload-pages-artifact@v5.0.0':
186188
ref: 'v5.0.0'
187189
commit: 'sha1-fc324d3547104276b827a68afc52ff2a11cc49c9'

‎scripts/ci/pin-workflow-uses.py‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,34 @@ def build_lock(pins: dict[str, dict[str, str]], existing: str) -> str:
284284
out.append("dependencies:")
285285
merged = dict(preserved)
286286
merged.update(new_blocks)
287+
288+
# A composite action's own dependencies are recorded on whichever entry
289+
# `gh actions-lock` happened to write them against — in practice the
290+
# TAG-keyed one. GitHub resolves them from the entry the workflow actually
291+
# names, which after a re-pin is the SHA-keyed one. Carry the `uses:` list
292+
# across to every entry describing the same commit, or a re-pinned workflow
293+
# dies in Set up job with "lockfile missing pin for <the nested action>".
294+
deps_by_commit: dict[str, list[str]] = {}
295+
for lines in merged.values():
296+
fields = block_fields(lines)
297+
if "uses" in fields or any(l.lstrip().startswith("uses:") for l in lines):
298+
pass
299+
try:
300+
idx = next(i for i, l in enumerate(lines) if l.strip() == "uses:")
301+
except StopIteration:
302+
continue
303+
commit = fields.get("commit", "")
304+
if commit:
305+
deps_by_commit.setdefault(commit, lines[idx:])
306+
307+
for key, lines in merged.items():
308+
if any(l.strip() == "uses:" for l in lines):
309+
continue
310+
commit = block_fields(lines).get("commit", "")
311+
extra = deps_by_commit.get(commit)
312+
if extra:
313+
merged[key] = lines + list(extra)
314+
287315
for key in sorted(merged):
288316
out.extend(merged[key])
289317
return "\n".join(out) + "\n"

0 commit comments

Comments
 (0)