Skip Sourcery review job for fork-originated pull requests#517
Merged
Conversation
Agent-Logs-Url: https://github.com/kimocoder/wifite2/sessions/e84e498f-7b09-4656-a234-51fc1456e6ce Co-authored-by: kimocoder <4252297+kimocoder@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Sourcery action for forked pull requests
Skip Sourcery review job for fork-originated pull requests
May 21, 2026
There was a problem hiding this comment.
Pull request overview
This PR updates the Sourcery PR-check workflow to avoid running on fork-originated pull requests, where repository secrets are not available and the Sourcery action fails due to a missing token.
Changes:
- Added a job-level
if:condition to runreview-with-sourceryonly when the PR head repository matches the base repository. - Documented the reason for the condition with an inline comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Check PR using Sourceryfails on fork PRs becausepull_requestworkflows do not receive repository secrets, sosecrets.WIFITEis empty and Sourcery is invoked with a missing--tokenvalue. This change prevents the job from running when the PR head repo is not the base repo.Workflow gating
review-with-sourceryin.github/workflows/checkpr-sourcery.yml:github.event.pull_request.head.repo.full_name == github.repositoryScope
.github/workflows/checkpr-sourcery.ymlOriginal prompt
The
Check PR using Sourceryworkflow (.github/workflows/checkpr-sourcery.yml) fails on pull requests from forks with:Cause
The workflow uses
on: pull_requestand passestoken: ${{ secrets.WIFITE }}to thesourcery-ai/action@v1step. GitHub Actions does not expose repository secrets to workflows triggered bypull_requestevents from forked repositories, sosecrets.WIFITEresolves to an empty string. The Sourcery action then invokes its CLI with--tokenfollowed by no value, causing the error above. This is currently breaking PRs such as #510 (from a fork).Fix (Option 1 — skip on fork PRs)
Add a job-level
ifcondition so the Sourcery review job only runs when the PR head repository is the same as the base repository (i.e., not a fork), where secrets are available.Update
.github/workflows/checkpr-sourcery.ymlto:Acceptance criteria
.github/workflows/checkpr-sourcery.ymlis modified.review-with-sourceryjob has anif:expression that skips it when the PR head repo is not the same as the base repo.kimocoder/wifite2.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: How to fix the sourcery workflow?
Assistant: The Sourcery workflow is failing with:
Root cause
In
.github/workflows/checkpr-sourcery.ymlthe action is invoked with:The secret
WIFITEis empty (or unavailable in this context), so the Sourcery action ends up calling its CLI with--tokenfollowed by no value, which causes the "Option '--token' requires an argument" error.There are two common reasons the secret resolves to an empty string:
SOURCERY_TOKEN).pull_requestevents from forks, so${{ secrets.WIFITE }}is empty. PR Improve cracking command output and config defaults #510 is from a fork (Ashcal9669:master→kimocoder:master), which is exactly the case here.How to fix it
Pick one of these approaches:
Option 1 — Skip Sourcery on fork PRs (recommended, simplest)
Guard the job so it doesn't run when no token is available:
You can also add a step-level guard
if: env.TOKEN != ''if you'd rather keep the job running for other steps.Option 2 — Use
pull_request_targetso secrets are availableReplace⚠️ This exposes secrets to PRs from forks, so do not check out and execute untrusted PR code. For Sourcery (which only reads the diff) this is generally safe, but be careful if you add other steps.
on: pull_requestwithon: pull_request_target.Option 3 — Verify the secret exists and is named correctly
Go to Settings → Secrets and variables → Actions in
kimocoder/wifite2and confirm a secret namedWIFITEexists and contains a valid Sourcery token. The Sourcery docs suggest naming itSOURCERY_TOKEN; if you rename it, update the workflow accordingly:For PR #510 specifically, the workflow will keep failing until either (a) the workflow is changed to skip fork PRs (Option 1), or (b) it's switched to
pull_request_target(Option 2). Even if theWIFITEsecret is valid, it will never be injected into a PR coming from a fork und...This pull request was created from Copilot chat.