Skip to content

Add fork guard to extension-template-sync workflow#636

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-if-condition-to-workflow
Draft

Add fork guard to extension-template-sync workflow#636
Copilot wants to merge 2 commits into
mainfrom
copilot/add-if-condition-to-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

The extension-template-sync Copilot agent workflow was running in forked repositories, which is undesirable.

Change

Added if: github.repository == 'microsoft/vscode-isort' to the frontmatter of .github/workflows/extension-template-sync.md, between the on: block and permissions::

on:
  schedule:
    - cron: daily
  workflow_dispatch:
if: github.repository == 'microsoft/vscode-isort'
permissions:
  ...
Original prompt

Add if: github.repository == 'microsoft/vscode-isort' to the frontmatter of .github/workflows/extension-template-sync.md so the workflow does not run in forked repositories.

Add the if: line right after the on: block and before permissions: in the YAML frontmatter.

The following is the prior conversation context from the user's chat exploration (may be truncated):

User: How do i make this workflow not run in forks ?

Assistant: This is a Copilot coding agent workflow (.md file), not a standard GitHub Actions YAML workflow. To prevent it from running in forks, add an if condition to the frontmatter using the github.repository context variable:

on:
  schedule:
    - cron: daily
  workflow_dispatch:
if: github.repository == 'microsoft/vscode-isort'

Add the if: line right after the on: block (and before permissions:). This ensures the workflow only executes when the repository is the original microsoft/vscode-isort and not any fork of it.

User: Can you create a PR on microsoft/vscode-isort, microsoft/vscode-pylint, microsoft/vscode-mypy, microsoft/vscode-flake8 and microsoft/vscode-black-formatter ?

Assistant: I'll create PRs on all 5 repositories to add the fork guard to the extension-template-sync.md workflow.

Assistant: I've kicked off PR creation on all 5 repositories. Each will add the if: github.repository == '...' guard to .github/workflows/extension-template-sync.md:

Repository if condition
microsoft/vscode-isort github.repository == 'microsoft/vscode-isort'
microsoft/vscode-pylint github.repository == 'microsoft/vscode-pylint'
microsoft/vscode-mypy github.repository == 'microsoft/vscode-mypy'
microsoft/vscode-flake8 github.repository == 'microsoft/vscode-flake8'
microsoft/vscode-black-formatter github.repository == 'microsoft/vscode-black-formatter'

The PRs are being prepared now — you'll see them appear shortly in each repo.

This pull request was created from Copilot chat.

Copilot AI changed the title [WIP] Add if condition to prevent workflow in forks Add fork guard to extension-template-sync workflow Apr 17, 2026
Copilot AI requested a review from edvilme April 17, 2026 18:32
Copy link
Copy Markdown
Contributor

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

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

Approved via Review Center.

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.

3 participants