1
- name : Update Dependencies
2
-
1
+ name : Update dependencies
3
2
on :
4
3
schedule :
5
4
- cron : ' 0 0 * * 0' # Runs at 00:00 every Sunday
6
- workflow_dispatch : # Allows manual triggering
5
+ workflow_dispatch :
6
+ inputs :
7
+ pr_branch :
8
+ description : ' Branch to push changes to (optional)'
9
+ required : false
10
+ type : string
11
+ workflow_call :
12
+ inputs :
13
+ pr_branch :
14
+ description : ' Branch to push changes to'
15
+ required : true
16
+ type : string
7
17
8
18
jobs :
9
- update-dependencies :
19
+ update-deps :
10
20
runs-on : ubuntu-latest
11
21
permissions :
12
22
contents : write
13
23
pull-requests : write
14
24
steps :
15
25
- uses : actions/checkout@v4
26
+
16
27
- name : Setup PDM
17
28
uses : pdm-project/setup-pdm@v4
18
29
with :
19
30
cache : true
31
+
20
32
- name : Lock dependencies
21
33
run : pdm lock
34
+
22
35
- name : Export requirements
23
36
run : pdm run export
37
+
24
38
- name : Check for changes
25
39
id : git-check
26
40
run : |
27
41
git diff --exit-code --quiet requirements.txt || echo "changed=true" >> $GITHUB_OUTPUT
28
- - name : Create Pull Request
42
+
43
+ - name : Handle dependency updates
29
44
if : steps.git-check.outputs.changed == 'true'
30
45
run : |
31
46
git config user.name github-actions
32
47
git config user.email [email protected]
33
- git checkout -b update-dependencies-${{ github.run_id }}
34
- git add requirements.txt pyproject.toml pdm.lock
35
- git commit -m "Update dependencies"
36
- git push origin update-dependencies-${{ github.run_id }}
37
- gh pr create --title "Update dependencies" --body "This PR updates the project dependencies. Please review the changes and merge if everything looks good." --base ${{ github.ref_name }} --head update-dependencies-${{ github.run_id }}
48
+
49
+ if [ -n "${{ inputs.pr_branch }}" ]; then
50
+ # Push to existing branch
51
+ BRANCH_NAME=$(echo ${{ inputs.pr_branch }} | cut -d'/' -f 3)
52
+ git checkout $BRANCH_NAME
53
+ git add requirements.txt pyproject.toml pdm.lock
54
+ git commit -m "Update dependencies"
55
+ git push origin $BRANCH_NAME
56
+ else
57
+ # Create new branch and PR
58
+ NEW_BRANCH="update-dependencies-${{ github.run_id }}"
59
+ git checkout -b $NEW_BRANCH
60
+ git add requirements.txt pyproject.toml pdm.lock
61
+ git commit -m "Update dependencies"
62
+ git push origin $NEW_BRANCH
63
+
64
+ gh pr create \
65
+ --title "Update dependencies" \
66
+ --body "This PR updates the project dependencies. Please review the changes and merge if everything looks good." \
67
+ --base ${{ github.ref_name }} \
68
+ --head $NEW_BRANCH
69
+ fi
38
70
env :
39
71
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments