-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.79 KB
/
Copy pathlock_file_management.yml
File metadata and controls
57 lines (48 loc) · 1.79 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
name: Sync uv.lock on pyproject.toml and exporting requirements.txt.
on:
pull_request:
branches:
- main
paths:
- 'pyproject.toml'
- 'requirements.txt'
- 'uv.lock'
# allow manual dispatch of this workflow
workflow_dispatch:
jobs:
uv-lock-management:
runs-on: ubuntu-latest
permissions:
contents: write
timeout-minutes: 1
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
ref: ${{ github.event.pull_request.head.ref }}
# see https://docs.astral.sh/uv/guides/integration/github/#setting-up-python for more details.
- name: Install uv
uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
with:
version: "0.11.8"
- name: "Set up Python"
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6
with:
python-version-file: ".python-version"
- name: Update lock files with latest pyproject.toml
run: uv lock
- name: Export requirements.txt
run: |
uv export --frozen --no-dev --no-editable --no-hashes --no-emit-project > requirements.txt
- name: Commit change if needed
run: |
git config --global user.name "github-actions[bot]+sync-lockfile"
git config --global user.email "github-actions[bot]+sync-lockfile@users.noreply.github.com"
if git diff --exit-code uv.lock requirements.txt; then
echo "skip commit as there is no change"
else
echo "uv.lock and/or requirements.txt are updated, commit change ..."
git add uv.lock requirements.txt
git commit -m "[GHA] update uv.lock and/or requirements.txt"
git push
fi