From 14dac92968097a642aa85b3f1665a43441714f2f Mon Sep 17 00:00:00 2001 From: Susanne Windfeld Pedersen Date: Thu, 28 May 2026 14:09:15 +0200 Subject: [PATCH] =?UTF-8?q?Remove=20pr-labeler=20workflow=20=E2=80=94=20un?= =?UTF-8?q?blocks=20fork=20PRs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The pr-labeler workflow is failing on fork PRs with permission errors that persist even after switching to pull_request_target. Removing it entirely to unblock contributors. The workflow will be re-added once properly tested in a private fork. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr-labeler.yml | 261 ------------------------------- 1 file changed, 261 deletions(-) delete mode 100644 .github/workflows/pr-labeler.yml diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml deleted file mode 100644 index d850e404a9..0000000000 --- a/.github/workflows/pr-labeler.yml +++ /dev/null @@ -1,261 +0,0 @@ -name: "PR Labeler" - -on: - pull_request_target: - types: [opened, synchronize] - -jobs: - label-pr: - # Only run on the public repo — prevents execution if synced to private - if: github.repository == 'MicrosoftDocs/dynamics365smb-devitpro-pb' - runs-on: ubuntu-latest - permissions: - contents: read - issues: write - pull-requests: write - - steps: - - name: Checkout PR head - uses: actions/checkout@v4 - with: - # Fetch the PR head so we can diff against the base - ref: ${{ github.event.pull_request.head.sha }} - fetch-depth: 0 - - - name: Fetch base branch - run: git fetch origin ${{ github.event.pull_request.base.ref }} - - - name: Get changed files - id: changed - run: | - # Get the list of changed files in the PR - git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.event.pull_request.head.sha }} > changed_files.txt - echo "Changed files:" - cat changed_files.txt - - - name: Analyze PR and assign labels - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const fs = require('fs'); - const { execSync } = require('child_process'); - - const changedFiles = fs.readFileSync('changed_files.txt', 'utf8') - .split('\n') - .filter(f => f.trim().length > 0); - - const labels = new Set(); - - // --- Path-based labels --- - const pathRules = [ - { pattern: /^properties\//, label: 'reference-docs' }, - { pattern: /^triggers\//, label: 'reference-docs' }, - { pattern: /^dev-itpro\/.*\/analyzers\//, label: 'reference-docs' }, - { pattern: /^dev-itpro\/.*\/attributes\//, label: 'reference-docs' }, - { pattern: /^dev-itpro\/.*\/methods-auto\//, label: 'reference-docs' }, - { pattern: /^dev-itpro\/.*\/triggers-auto\//, label: 'reference-docs' }, - { pattern: /^dev-itpro\/.*\/api\//, label: 'api' }, - { pattern: /^onprem\//, label: 'on-prem' }, - { pattern: /^dev-itpro\/upgrade\//, label: 'upgrade' }, - { pattern: /^dev-itpro\/administration\//, label: 'administration' }, - { pattern: /^dev-itpro\/developer\//, label: 'developer' }, - { pattern: /^dev-itpro\/security\//, label: 'security' }, - ]; - - for (const file of changedFiles) { - for (const rule of pathRules) { - if (rule.pattern.test(file)) { - labels.add(rule.label); - } - } - } - - // --- Content-based analysis --- - let totalAdditions = 0; - let totalDeletions = 0; - let hasCodeChanges = false; - let hasDoNotEditChanges = false; - let isTypoOnly = true; - - // Get the full diff - const diff = execSync( - `git diff origin/${process.env.BASE_REF}...${process.env.HEAD_SHA}`, - { encoding: 'utf8', maxBuffer: 10 * 1024 * 1024 } - ); - - // Parse diff by file - const fileDiffs = diff.split(/^diff --git /m).filter(d => d.length > 0); - - for (const fileDiff of fileDiffs) { - const lines = fileDiff.split('\n'); - - const fileMatch = fileDiff.match(/^a\/(.+?) b\//); - if (!fileMatch) continue; - const filePath = fileMatch[1]; - - // Only analyze markdown files - if (!filePath.endsWith('.md')) continue; - - // Count additions and deletions - let inHunk = false; - let addedLines = []; - let removedLines = []; - - for (const line of lines) { - if (line.startsWith('@@')) { - inHunk = true; - continue; - } - if (!inHunk) continue; - - if (line.startsWith('+') && !line.startsWith('+++')) { - addedLines.push(line.substring(1)); - totalAdditions++; - } else if (line.startsWith('-') && !line.startsWith('---')) { - removedLines.push(line.substring(1)); - totalDeletions++; - } - } - - // Check for code block changes (fenced code in AL, json, xml, etc.) - const codeBlockPattern = /^```\s*(al|json|xml|yaml|powershell|csharp|cs|javascript|js)/i; - - for (const line of addedLines.concat(removedLines)) { - if (codeBlockPattern.test(line.trim())) { - continue; - } - if (line.match(/^\s*(trigger|procedure|local|var|begin|end;|if |then|else|exit\(|record\s|codeunit\s|page\s|table\s)/i)) { - hasCodeChanges = true; - } - } - - // Check for inline code additions (full code blocks added/modified) - const allChangedText = addedLines.concat(removedLines).join('\n'); - if (allChangedText.match(/```(al|json|xml|yaml|powershell|csharp)/i)) { - hasCodeChanges = true; - } - - // Check if changes touch DO_NOT_EDIT sections - if (fs.existsSync(filePath)) { - const content = fs.readFileSync(filePath, 'utf8'); - // Match DO_NOT_EDIT blocks using the actual closing marker format. - // AL reference uses: [//]: # (IMPORTANT: END>DO_NOT_EDIT) - // API reference uses: - // The previous pattern matched prematurely on the instructional comment - // "between here and the END>DO_NOT_EDIT" — fixed by requiring the - // closing marker prefix (IMPORTANT: or '; - const alreadyPosted = comments.data.some(c => c.body.includes(marker)); - - if (!alreadyPosted) { - const body = marker + '\n' + - `⚠️ **Auto-generated content edited**\n\n` + - `This PR modifies content inside \`DO_NOT_EDIT\` markers. ` + - `These sections are regenerated from source and your changes ` + - `will be overwritten on the next refresh.\n\n` + - `**What to do:**\n` + - `- If you're fixing a bug in auto-generated content (syntax, description, parameters), ` + - `the fix needs to go in the source \`.xml\` files in the ModernDev repo instead.\n` + - `- If you're adding remarks, examples, or related information, move your content ` + - `**below** the \`END>DO_NOT_EDIT\` marker where it will be preserved.\n\n` + - `See the contribution guide for details on which sections are safe to edit.`; - - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - body: body, - }); - } - } - env: - BASE_REF: ${{ github.event.pull_request.base.ref }} - HEAD_SHA: ${{ github.event.pull_request.head.sha }}