Skip to content

Run CodeQL only on the template repository - #10

Merged
Pierre Malarme (pmalarme) merged 1 commit into
mainfrom
pmalarme-codeql-template-only
Jul 8, 2026
Merged

Run CodeQL only on the template repository#10
Pierre Malarme (pmalarme) merged 1 commit into
mainfrom
pmalarme-codeql-template-only

Conversation

@pmalarme

Copy link
Copy Markdown
Collaborator

Problem

When a student uses this repo via Use this template, the created repo doesn't have code scanning enabled. The CodeQL analyze job's upload step then fails, making the branch appear to crash for every student instance.

Fix

Guard the analyze job in .github/workflows/codeql-analysis.yml so it runs only on the canonical template repository:

if: github.repository == 'Azure-Samples/foundry-hosted-agents-workshop'
  • Student-created repos skip the job entirely and stay green.
  • The template still gets full CodeQL coverage.

Why match by repo name instead of is_template

The schedule trigger doesn't populate github.event.repository, so an is_template-based check would silently disable the weekly scan on the template too. Matching the source repo name works uniformly across push, pull_request, workflow_dispatch, and schedule.

Repos created from this template don't have code scanning enabled, so the CodeQL analyze/upload step fails and the branch appears to crash. Guard the analyze job to run only on the canonical template repo, which works across all triggers including schedule.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@pmalarme
Pierre Malarme (pmalarme) merged commit e7f53f2 into main Jul 8, 2026
7 checks passed
@pmalarme
Pierre Malarme (pmalarme) deleted the pmalarme-codeql-template-only branch July 8, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant