1+ name : Sync Requirements
2+
3+ on :
4+ pull_request :
5+ paths :
6+ - ' pyproject.toml'
7+ - ' uv.lock'
8+ types : [opened, synchronize, reopened]
9+
10+ jobs :
11+ sync-requirements :
12+ # Only run on Renovate PRs to avoid conflicts
13+ if : startsWith(github.head_ref, 'renovate/')
14+ runs-on : ubuntu-latest
15+
16+ permissions :
17+ contents : write
18+ pull-requests : write
19+
20+ steps :
21+ - name : Checkout repository
22+ uses : actions/checkout@v4
23+ with :
24+ # Use the head ref for PRs to commit back to the PR branch
25+ ref : ${{ github.head_ref }}
26+ token : ${{ secrets.GITHUB_TOKEN }}
27+
28+ - name : Install uv
29+ uses : astral-sh/setup-uv@v6
30+ with :
31+ version : " latest"
32+
33+ - name : Set up Python
34+ uses : actions/setup-python@v5
35+ with :
36+ python-version-file : " .python-version"
37+
38+ - name : Generate requirements.txt
39+ run : |
40+ echo "Generating requirements.txt from uv.lock..."
41+ uv export --frozen > requirements.txt
42+
43+ # Check if requirements.txt was modified
44+ if git diff --quiet requirements.txt; then
45+ echo "requirements.txt is already up to date"
46+ echo "requirements_updated=false" >> $GITHUB_ENV
47+ else
48+ echo "requirements.txt has been updated"
49+ echo "requirements_updated=true" >> $GITHUB_ENV
50+ fi
51+
52+ - name : Commit and push changes
53+ if : env.requirements_updated == 'true'
54+ run : |
55+ git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
56+ git config --local user.name "github-actions[bot]"
57+
58+ git add requirements.txt
59+ git commit -m "chore(deps): sync requirements.txt with uv.lock
60+
61+ Auto-generated by GitHub Actions from uv export"
62+
63+ git push
64+
65+ - name : Comment on PR
66+ if : env.requirements_updated == 'true'
67+ uses : actions/github-script@v7
68+ with :
69+ script : |
70+ github.rest.issues.createComment({
71+ issue_number: context.issue.number,
72+ owner: context.repo.owner,
73+ repo: context.repo.repo,
74+ body: ':white_check_mark: **requirements.txt updated**\n\nGenerated from `uv.lock` using `uv export --no-hashes --frozen`'
75+ })
0 commit comments