-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (45 loc) · 1.87 KB
/
dependency-checker.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
53
name: Dependency-Updater
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
dependency_updater:
name: Dependency-Updater
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.8"
- name: Poetry Python dependeny updater
env:
GH_TOKEN: ${{ secrets.RENOVATE_TOKEN }}
run: |
git config --global user.name "SDK Updater Bot"
git config --global user.email "[email protected]"
pip install poetry
pr_name=$(echo "Dependency Updates")
make update-dependencies
branch_name="dependency-updater-${{ github.run_id }}"
git checkout -b "$branch_name"
if [ -n "$(git diff --name-only)" ]; then
for file in $(git diff --name-only | grep poetry.lock); do
# Extract the service for which the dependencies have been updated
dirpath=$(dirname $file)
git add "$file"
git commit -m "chore: dependency update for ${dirpath}"
done
# Check if a PR already exists for dependency updates
if gh pr list --state open | grep -q "${pr_name}"; then
echo "Pr for $dirpath already exists. Deleting old PR."
pr_number=$(gh pr list --state open --json number --search "$pr_name" -q '.[0].number')
gh pr close "$pr_number" --delete-branch
fi
git push --set-upstream origin "$branch_name"
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
else
echo "No changes detected. Skipping PR creation."
fi