ποΈ Only allow team members to modify dependencies (#1744)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sofie Van Landeghem Β· committed by GitHub Β· parent 6209ca0 Β· Browse files Β· 2 filesΒ·+55 addedβ0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+55 addedβ0 removed
- other:+55 addedβ0 removed
Provenance
- Commit
54889c9- Tree
26413e0- Author
Sofie Van Landeghem <svlandeg@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent
6209ca0
2 files changed+55 addedβ0 removed
added:.github/workflows/guard-dependencies.yml+52 added
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152name: Guard Dependencies
on: pull_request_target: # zizmor: ignore[dangerous-triggers] -- This workflow only reads context.payload metadata, never checks out PR code branches: [master] paths: - pyproject.toml - uv.lock
permissions: contents: read issues: write pull-requests: write
jobs: check-author: runs-on: ubuntu-latest steps: - name: Check if author is org member or allowed bot uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7 with: script: | const pr = context.payload.pull_request; const author = pr.user.login; const assoc = pr.author_association;
const botAllowlist = new Set(['dependabot[bot]']); const orgAuthorAssociations = new Set(['MEMBER', 'OWNER']);
const allowed = botAllowlist.has(author) || (assoc != null && orgAuthorAssociations.has(assoc));
if (!allowed) { await github.rest.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, issue_number: context.payload.pull_request.number, body: `This PR modifies dependency files (\`pyproject.toml\` or \`uv.lock\`), which is restricted to members of the **${context.repo.owner}** organization on GitHub.\n\nIf you need a dependency change, please [open a discussion](https://github.com/${context.repo.owner}/${context.repo.repo}/discussions/new) describing what you need and why.\n\nClosing this PR automatically.` });
await github.rest.pulls.update({ owner: context.repo.owner, repo: context.repo.repo, pull_number: context.payload.pull_request.number, state: 'closed' });
core.setFailed('Dependency changes are restricted to organization members.'); } else { console.log(`Author ${author} (author_association=${assoc}) is allowed to make dependency changes.`); }modified:docs/help-typer.md+3 added
191 unmodified lines192 * To add a new feature.193 * Make sure to add tests.194 * Make sure to add documentation if it's relevant.195 196+Note that PRs from non-team members are not allowed to modify `pyproject.toml` or `uv.lock`, to prevent supply chain risk.197+If you would like to add a new dependency, create a new [Discussion](https://github.com/fastapi/typer/discussions/categories/questions) to explain why.198+199 ## Help Maintain Typer200 201 Help me maintain **Typer**! π€202 50 unmodified lines