Skip to content

Commit 627328c

Browse files
FIX: Avoid PR format check workflow label permission failures on fork PRs (#151)
Work Item / Issue Reference > ADO Workitem: [AB#38032](https://sqlclientdrivers.visualstudio.com/c6d89619-62de-46a0-8b46-70b92a84d85e/_workitems/edit/38032) ### Summary The PR Formatting Check workflow fails with a 403 'Resource not accessible by integration' error when attempting to add size labels to pull requests from forked repositories. This occurs because the default GitHub Actions token does not have permission to modify issue labels when the PR originates from a fork. ## Solution Added a conditional check to the "Add size label based on PR diff" step to only run when the PR originates from the main repository, not a fork: ```yaml - name: Add size label based on PR diff if: github.event.pull_request.head.repo.full_name == github.repository uses: actions/github-script@v7 # ... rest of the step ``` ## Impact - ✅ PRs from the main repository continue to work as before (size labels are added automatically) - ✅ PRs from forks skip the label-adding step, preventing the 403 permission error - ✅ All other workflow functionality (title validation, description validation) remains unchanged for both main repo and fork PRs - ✅ Contributors from forks can now submit PRs without encountering workflow failures ## Testing - Validated YAML syntax is correct - Confirmed the change is minimal and surgical (single line addition) - The conditional expression follows GitHub Actions best practices for fork detection This fix ensures the workflow remains functional for all contributors while respecting GitHub's permission model for forked repositories. *This pull request was created as a result of the following prompt from Copilot chat.* > The PR Formatting Check workflow fails with a 403 'Resource not accessible by integration' error when attempting to add labels to pull requests from forks. This is due to the default GitHub Actions token not having permission to modify issue labels from forked repositories. > > To resolve this, update the '.github/workflows/pr-format-check.yml' so that the step adding labels based on PR diff only runs if the PR originates from the main repository, not a fork. > > Add the following condition to the label-adding step: > > ```yaml > - name: Add size label based on PR diff > if: github.event.pull_request.head.repo.full_name == github.repository > uses: actions/github-script@v7 > with: > script: | > # ...existing script... > ``` > > This change prevents the workflow from attempting to modify labels when permissions are insufficient, avoiding the 403 error. <!-- START COPILOT CODING AGENT TIPS --> --- 💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click [here](https://survey.alchemer.com/s3/8343779/Copilot-Coding-agent) to start the survey. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: bewithgaurav <8655500+bewithgaurav@users.noreply.github.com>
1 parent f278d60 commit 627328c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

.github/workflows/pr-format-check.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ jobs:
7272
core.setFailed(`❌ PR must contain a meaningful summary section with actual text content (minimum 10 characters).\nPlease add a clear description under the '### Summary' heading in your PR description.`);
7373
}
7474
- name: Add size label based on PR diff
75+
if: github.event.pull_request.head.repo.full_name == github.repository
7576
uses: actions/github-script@v7
7677
with:
7778
script: |

0 commit comments

Comments
 (0)