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