-
Notifications
You must be signed in to change notification settings - Fork 10
78 lines (62 loc) · 2.36 KB
/
upgrade_pip_dependencies.yml
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
76
77
78
name: Upgrade pip dependencies
on:
schedule:
# first day of the month at 05:05AM
- cron: "5 5 1 * *"
workflow_dispatch:
jobs:
upgrade:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Python 3.11
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install poetry
uses: snok/install-poetry@v1
with:
version: 1.6.0
- name: Install dependencies
run: poetry install
- name: Upgrade dependencies
run: |
source $(poetry env info --path)/bin/activate
poetry up
- name: create pull request body
id: pr-body
run: |
diff_str=$(git diff poetry.lock || echo "")
# find the names of all modified dependencies
pr_body=$(echo "$diff_str" | grep -E "name\s*=\s*\"")
# remove removed dependencies
pr_body=$(echo "$pr_body" | sed 's/^\s*\-name\s*=\s*\"\([^\"]*\)\"\s*$//g' | sed '/^$/d')
# add pypi links to new and upgraded dependencies
pr_body=$(echo "$pr_body" | sed "s/^\s*[\+]*name\s*=\s*\"\([^\"]*\)\"\s*$/\* [\`\1\`](https:\/\/pypi.org\/project\/\1\)/g")
pr_body="## Upgrade pip dependencies\n\nThis **pull request** upgrades:\n\n$pr_body\n\nThe list items above have been pulled from the \`poetry.lock\` file.\n\nThe pull request will be updated by subsequent runs of the GitHub Actions workflow that generated it.\n"
echo -e "\n----------------------\nThe pull request body:\n----------------------\n"
echo -e "$pr_body"
echo 'pr_body<<EOF' >> $GITHUB_OUTPUT
echo -e "$pr_body" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
add-paths: |
poetry.lock
pyproject.toml
commit-message: "chore(deps): upgrade pip dependencies"
branch: upgrade-pip-dependencies
delete-branch: true
base: master
title: "Upgrade pip dependencies"
body: ${{ steps.pr-body.outputs.pr_body }}
labels: |
dependencies
python
draft: false