-
Notifications
You must be signed in to change notification settings - Fork 1
48 lines (41 loc) · 1.35 KB
/
gen_requirements_txt.yaml
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
name: gen requirements.txt on pyproject.toml file changed
on:
pull_request:
branches:
- main
paths:
- 'pyproject.toml'
# allow manual dispatch of this workflow
workflow_dispatch:
jobs:
gen-requirements-txt:
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- name: checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: setup python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: generate requirements.txt
run: |
python .github/tools/gen_requirements_txt.py \
pyproject.toml requirements.txt
- name: commit change if needed
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
if git diff --exit-code requirements.txt; then
echo "skip commit as requirements.txt is not changed"
else
echo "detect requirements.txt updated, commit change ..."
git add requirements.txt
git commit -m "[GHA] Update requirements.txt on pyproject.toml changed"
git push
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}