fix(template-sync): grant caller job write so the run doesn't fail at startup#7
Merged
Merged
Conversation
… startup
The Template Sync workflow declares top-level `permissions: {}`, but the
reusable `template-sync.yaml` job it calls needs `contents: write` +
`pull-requests: write` to open the sync PR. A reusable workflow cannot be
granted more than its caller, so the call fails the reusable-workflow
permission check at startup — before the `if` guard can skip it on the
template repo, and identically in every tenant where the job is meant to run.
The weekly schedule fired for the first time on 2026-06-01 and surfaced this
as a `startup_failure`.
Grant the caller's `template-sync` job the two write scopes the reusable
workflow requires (matching the README's `update-agent-skills` caller
example), keeping the least-privilege top-level `permissions: {}` for the
rest of the workflow.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes the scheduled Template Sync GitHub Actions workflow startup failure by granting the calling job the minimal write permissions required by the referenced reusable workflow, while keeping workflow-wide permissions disabled.
Changes:
- Adds job-level
permissions(contents: write,pull-requests: write) to thetemplate-syncjob so the reusable workflow can open PRs without failing at workflow setup time. - Documents why the permissions are required (reusable workflow permission ceiling vs. caller).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The weekly
🔄 Template Syncschedule fired for the first time today (2026-06-01, a Monday) and the run failed at startup (startup_failure, run 26741819812) rather than skipping on the template repo as intended.Root cause: the caller declares top-level
permissions: {}, but the reusabletemplate-sync.yamljob it calls requirescontents: write+pull-requests: writeto open the sync PR. A reusable workflow cannot be granted more permissions than its caller, so the call fails the reusable-workflow permission check during workflow setup — which happens before the job-levelifguard can skip it on the template repo.This is not just template-repo noise: the identical failure occurs in every tenant, where
if: github.repository != …templateis true and the job is meant to actually run. As shipped, the template's core sync feature is dead-on-arrival for all tenants created from it.Fix
Grant the caller's
template-syncjob the two write scopes the reusable workflow requires, keeping the least-privilege top-levelpermissions: {}for the rest of the workflow. This matches the reusable-workflows README's ownupdate-agent-skillscaller example, which sets job-levelcontents: write+pull-requests: writeon the calling job.Validation
actionlint .github/workflows/template-sync.yaml→ exit 0workflow_dispatch) run will correctly skip on the template repo (guardedif) instead of failing at startup, and the synced workflow will have the permissions it needs to run in tenants.Note for tenants
Existing tenants (e.g. ascoachingogvaner, wedding-app) carry their own copy of this caller; they will pick up the corrected permissions on the next template sync once this lands, or can be patched directly with the same two-line
permissions:block.