diff --git a/internal/scaffold/fullsend-repo/templates/shim-per-repo.yaml b/internal/scaffold/fullsend-repo/templates/shim-per-repo.yaml index 2bd85b0495..6b48a10a95 100644 --- a/internal/scaffold/fullsend-repo/templates/shim-per-repo.yaml +++ b/internal/scaffold/fullsend-repo/templates/shim-per-repo.yaml @@ -31,8 +31,12 @@ permissions: {} jobs: dispatch: + # #7895: forks inherit this file but not repository variables, so an + # unset FULLSEND_MINT_URL skips agent jobs without a runner or a + # failed check. Re-onboard sets the variable and the same file runs. if: >- - (github.event_name != 'pull_request_target' && github.event_name != 'pull_request_review' + vars.FULLSEND_MINT_URL != '' + && (github.event_name != 'pull_request_target' && github.event_name != 'pull_request_review' || github.event.pull_request.head.ref != 'fullsend/scaffold-install') && (github.event_name != 'issue_comment' || (startsWith(github.event.comment.body, '/fs-') @@ -66,7 +70,8 @@ jobs: # hatch) is made in the step below, so a maintainer whose author_association # is not MEMBER (e.g. private org membership) is not filtered out (ADR 0054). if: >- - github.event_name == 'issue_comment' + vars.FULLSEND_MINT_URL != '' + && github.event_name == 'issue_comment' && github.event.issue.pull_request && github.event.comment.user.type != 'Bot' && github.event.comment.body == '/fs-fix-stop' diff --git a/internal/scaffold/scaffold_test.go b/internal/scaffold/scaffold_test.go index 58cbca9df9..24c343d1f2 100644 --- a/internal/scaffold/scaffold_test.go +++ b/internal/scaffold/scaffold_test.go @@ -211,6 +211,29 @@ func TestShimPerRepoTemplateContent(t *testing.T) { }, pr.Jobs.StopFix.Permissions, "stop-fix job permissions") } +// TestShimPerRepoSkipsWhenMintURLUnset verifies forks of enrolled repos +// do not run agent jobs (#7895). GitHub does not copy repository +// variables to forks, so FULLSEND_MINT_URL is empty there. +func TestShimPerRepoSkipsWhenMintURLUnset(t *testing.T) { + content, err := FullsendRepoFile("templates/shim-per-repo.yaml") + require.NoError(t, err) + + var wf struct { + Jobs map[string]struct { + If string `yaml:"if"` + } `yaml:"jobs"` + } + require.NoError(t, yaml.Unmarshal(content, &wf)) + + const gate = "vars.FULLSEND_MINT_URL != ''" + for _, job := range []string{"dispatch", "stop-fix"} { + cond := wf.Jobs[job].If + require.NotEmpty(t, cond, "%s job must have an if condition", job) + assert.Contains(t, cond, gate, + "%s job must skip when FULLSEND_MINT_URL is unset", job) + } +} + // TestShimStopFixAuthorization verifies the stop-fix job authorizes the // /fs-fix-stop command via the collaborator permission API (ADR 0054) rather // than author_association. See issue #5421: author_association grants