Skip to content

[ci] Prevent scheduled workflows from running in forks - #37749

Merged
kubaflo merged 4 commits into
dotnet:mainfrom
kubaflo:ci/disable-scheduled-workflows-in-forks
Aug 25, 2026
Merged

kubaflo merged 4 commits into
dotnet:mainfrom
kubaflo:ci/disable-scheduled-workflows-in-forks

Conversation

@kubaflo

@kubaflo kubaflo commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Summary

  • gate every previously unguarded scheduled workflow root job to the canonical dotnet/maui repository
  • gate agentic workflow pre_activation jobs so forks cannot reach PAT selection or Copilot inference
  • preserve regression scanner candidate and trusted-branch checks as additive activation conditions
  • make the seven-day gh-aw action-failure issue expiry an explicit repository policy
  • regenerate the affected gh-aw lock files

Why

Forks that enable GitHub Actions inherit scheduled workflows from this repository. Without repository guards, those schedules can consume fork owner Actions minutes and Copilot credits even when the fork is otherwise idle.

Every scheduled workflow now has an upstream-only condition on each root job. A scheduled run recorded by GitHub in a fork therefore contains only skipped jobs and consumes no runner or inference work.

Manual workflow_dispatch runs can select an arbitrary ref, so the regression scanner trusted-main restriction also covers pre_activation, where checkout and deterministic PowerShell execute with GH_TOKEN before agent activation.

Current-main gh-aw defaults action-failure issues to a seven-day lifetime. .github/workflows/aw.json records that policy explicitly so regenerated locks do not introduce an undocumented retention change.

Validation

  • main-pinned gh-aw v0.86.2 strict compilation with --validate --no-check-update
  • 591 targeted Pester tests across the CI scanner workflow suites
  • 77 focused Find-RegressionFixPRs Pester tests
  • structural check covering every scheduled workflow root job

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 22, 2026 21:19
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:20 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37749

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37749"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:20 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:20 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:23 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:23 — with GitHub Actions Inactive
@github-actions github-actions Bot added the area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions label Aug 22, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 21:24 — with GitHub Actions Inactive
@kubaflo kubaflo added the area-ai-agents Copilot CLI agents, agent skills, AI-assisted development label Aug 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates scheduled and agentic workflows to run only in the canonical dotnet/maui repository.

Changes:

  • Adds upstream repository guards to scheduled and pre-activation jobs.
  • Preserves regression-scanner activation checks.
  • Regenerates affected gh-aw lock files.

A critical issue remains: owner-only guards in other scheduled workflows can still allow forks under the dotnet organization to run.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
.github/workflows/validate-pat-pool.yml Restricts PAT validation.
.github/workflows/skill-evaluation-soak.yml Restricts soak execution.
.github/workflows/rerun-review-scanner.md Adds workflow-level repository guard.
.github/workflows/rerun-review-scanner.lock.yml Regenerated guarded workflow.
.github/workflows/release-readiness.yml Updates validation gating.
.github/workflows/regression-corpus-scanner.md Separates repository and activation guards.
.github/workflows/regression-corpus-scanner.lock.yml Regenerated guarded workflow.
.github/workflows/merge-net11-to-release.yml Guards scheduled merge jobs.
.github/workflows/merge-main-to-net11.yml Guards merge processing.
.github/workflows/daily-template-size-tracking.yml Guards matrix preparation.
.github/workflows/daily-repo-status.md Adds repository guard.
.github/workflows/daily-repo-status.lock.yml Regenerated guarded workflow.
.github/workflows/ci-status-net11.md Adds repository guard.
.github/workflows/ci-status-net11.lock.yml Regenerated guarded workflow.
.github/workflows/ci-status-main.md Adds repository guard.
.github/workflows/ci-status-main.lock.yml Regenerated guarded workflow.
Suppressed comments (1)

.github/workflows/release-readiness.yml:891

  • This job is the PR-validation path, not a scheduled writer. Adding the canonical-repository check means a fork's own pull_request runs no longer execute the validation suite, even though the workflow is read-only and the previous condition intentionally enabled validation for every pull request. Keep this condition event-based (or explicitly exempt pull_request) so the fork-protection change remains limited to scheduled/background execution.
    if: github.repository == 'dotnet/maui' && github.event_name == 'pull_request'

Comment thread .github/workflows/validate-pat-pool.yml Resolved
@kubaflo

kubaflo commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Confirmed both remaining review issues. The owner-only guards in dotnet-format-daily.yml, locker.yml, ci-scan-lock-issues.yml, and the scheduled pr-review-queue.yml job still permit a dotnet/* fork. Also, release-readiness.yml changed its PR-only, read-only validation job to require the canonical repository; that is broader than the scheduled/background isolation goal and disables validation for pull requests created within a fork. The exact repository check should be limited to scheduled/writer roots (or the validation condition should explicitly preserve pull_request). The branch is currently LIVE-owned in another session, so I am replying only and not colliding with its pending work.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 22, 2026 23:27
@kubaflo

kubaflo commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Implemented the carry-forward review findings in d186d52602:

  • Replaced the remaining owner-only writer/root guards with exact dotnet/maui checks in the four named workflows and in backport.yml, the additional schedule-bearing writer found by the complete scan.
  • Restored release-readiness to event-only PR validation so fork-local read-only validation remains available.
  • Recompiled all five changed gh-aw sources with the current-main pin (v0.86.2); the generated locks are idempotent.

Validation: every scheduled workflow root job is now canonical-repository guarded or explicitly PR-only; offline release-readiness suites passed (87 + 2,134 assertions).

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Suppressed comments (4)

.github/workflows/ci-status-main.lock.yml:1223

  • This lock regeneration also changes GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS from 0 to 168, although the corresponding source workflow has no failure-issue setting and this PR only adds repository guards. That changes the retention/cleanup behavior of gh-aw failure issues and is repeated in the other regenerated locks; please preserve the prior value or make the new expiry an explicit, documented source change.
          GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168"

.github/workflows/ci-status-net11.lock.yml:1224

  • This lock regeneration also changes GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS from 0 to 168, although the corresponding source workflow has no failure-issue setting and this PR only adds repository guards. That changes the retention/cleanup behavior of gh-aw failure issues and is repeated in the other regenerated locks; please preserve the prior value or make the new expiry an explicit, documented source change.
          GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168"

.github/workflows/daily-repo-status.lock.yml:1210

  • This lock regeneration also changes GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS from 0 to 168, although the corresponding source workflow has no failure-issue setting and this PR only adds repository guards. That changes the retention/cleanup behavior of gh-aw failure issues and is repeated in the other regenerated locks; please preserve the prior value or make the new expiry an explicit, documented source change.
          GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168"

.github/workflows/regression-corpus-scanner.lock.yml:1332

  • This lock regeneration also changes GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS from 0 to 168, although the corresponding source workflow has no failure-issue setting and this PR only adds repository guards. That changes the retention/cleanup behavior of gh-aw failure issues and is repeated in the other regenerated locks; please preserve the prior value or make the new expiry an explicit, documented source change.
          GH_AW_ACTION_FAILURE_ISSUE_EXPIRES_HOURS: "168"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 23, 2026 00:26
@kubaflo

kubaflo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Implemented the latest review in 543d373994:

  • Restored the trusted-main predicate at workflow level, so a non-main manual dispatch cannot reach pre_activation checkout or PowerShell.
  • Added .github/workflows/aw.json with maintenance.action_failure_issue_expires: 168, making the generated seven-day lock value an explicit repository policy rather than incidental compiler drift.
  • Recompiled with current-main-pinned gh-aw v0.86.2 in strict validation mode; compilation is idempotent and the focused scanner suite passes 77/77.

The PR description now documents both changes.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Comment thread .github/workflows/aw.json Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 23, 2026 02:14
@kubaflo

kubaflo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot-pull-request-reviewer addressed the latest feedback in 9535f58: all nine remaining stale gh-aw locks were regenerated with current-main-pinned v0.86.2 strict compilation, so all 14 generated workflows now use the repository-wide 168-hour failure-issue expiry. The compile was idempotent and the PR is MERGEABLE. This is ready for re-review — thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 30 out of 30 changed files in this pull request and generated no new comments.

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial Code Review — 3 independent reviewers with consensus

Verdict: Clean ✅

Three independent reviewers analyzed all 30 changed files (16 non-generated + 14 regenerated locks), tracing job dependency graphs, compiled lock output, and guard coverage. No correctness, security, or regression issues found.

Verified correct

  • Dependency cascades — All downstream jobs (e.g. Merge in merge workflows, build-and-measure/analyze-and-report in template-size-tracking) are transitively gated via needs edges with no always() override, so a skipped root job correctly cascades.
  • regression-corpus-scanner restructuring — Moving needs.pre_activation.outputs.has_candidates from workflow-level if to the activation job-level if is actually a fix: the old form would have been an invalid self-reference on pre_activation itself. The new structure correctly gates pre_activation with the repo/ref check while preserving the candidate condition on activation.
  • Security model — github.repository is immutable (forks cannot rename to dotnet/maui); no TOCTOU between if evaluation and runner allocation; environment secrets remain protected.
  • Lock regeneration — All 14 locks updated to EXPIRES_HOURS: "168" matching aw.json policy; no stale or unexpected drift.
  • No unguarded scheduled workflows remain — Cross-checked against all .yml/.lock.yml files with schedule triggers.

💡 Minor consistency note (2/3 reviewers, non-blocking)

.github/workflows/pr-review-queue.yml:91 — The validate job still uses the old github.repository_owner == 'dotnet' pattern while the sibling generate-report job (line 25) was converted to github.repository == 'dotnet/maui'. Since validate is pull_request-scoped and read-only, this is not a functional or security risk — just an incomplete conversion within a file this PR already edits. Could be aligned for consistency.


Methodology: 3 independent reviewers with adversarial consensus. Findings required 2/3+ agreement to be included.

@PureWeen PureWeen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adversarial review

No new correctness, security, or regression concerns found at 9535f5823518eb68938697bc7fd0b73f28308cfe.

Three independent reviewers reached adversarial consensus; each independent reviewer assessed the exact head.

@kubaflo
kubaflo merged commit 90afade into dotnet:main Aug 25, 2026
18 of 61 checks passed
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Aug 25, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-ai-agents Copilot CLI agents, agent skills, AI-assisted development area-infrastructure CI, Maestro / Coherency, upstream dependencies/versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants