-
Notifications
You must be signed in to change notification settings - Fork 4
52 lines (45 loc) · 1.81 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
49
50
51
52
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 }}
# use repo scope deploy key for the later git operations, so that the pushed commit can trigger the
# workflow as expected. The default action token GITHUB_TOKEN cannot trigger new workflows.
# For more details about this restriction, please refer to:
# https://github.com/peter-evans/create-pull-request/issues/48 and
# https://github.com/peter-evans/create-pull-request/blob/main/docs/concepts-guidelines.md#triggering-further-workflow-runs
ssh-key: ${{ secrets.DEPLOY_KEY }}
persist-credentials: true
- 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