Skip to content

Commit 3a608aa

Browse files
authored
chore: rework dependency updater (#431)
1 parent 9475828 commit 3a608aa

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

.github/workflows/dependency-checker.yaml

+24-24
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ jobs:
2424
git config --global user.email "noreply@stackit.de"
2525
2626
pip install poetry
27+
28+
pr_name=$(echo "Dependency Updates")
29+
2730
make update-dependencies
28-
for file in $(git diff --name-only | grep poetry.lock); do
29-
# Extract the service for which the dependencies have been updated
30-
dirpath=$(dirname $file)
31-
pr_name=$(echo "Dependency Updater: ${dirpath}")
32-
33-
# Check if a PR already exists for the package
34-
if gh pr list --state open | grep -q "${pr_name}"; then
35-
echo "Pr for $dirpath already exists. Deleting old PR."
36-
pr_number=$(gh pr list --state open --json number --search "$pr_name" -q '.[0].number')
37-
gh pr close "$pr_number" --delete-branch
31+
branch_name="dependency-updater-${{ github.run_id }}"
32+
git checkout -b "$branch_name"
3833
39-
fi
40-
41-
# Create PR
42-
branch_name="dependency-updater-$dirpath-${{ github.run_id }}"
43-
git checkout -b "$branch_name"
44-
git add "$file"
45-
git commit -m "chore: dependency update"
46-
git push --set-upstream origin "$branch_name"
47-
echo $(git status)
48-
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
49-
git checkout main
50-
sleep 30 # prevent rate limit.
51-
52-
done
34+
if [ -n "$(git diff --name-only)" ]; then
35+
for file in $(git diff --name-only | grep poetry.lock); do
36+
# Extract the service for which the dependencies have been updated
37+
dirpath=$(dirname $file)
38+
git add "$file"
39+
git commit -m "chore: dependency update for ${dirpath}"
40+
done
41+
42+
# Check if a PR already exists for dependency updates
43+
if gh pr list --state open | grep -q "${pr_name}"; then
44+
echo "Pr for $dirpath already exists. Deleting old PR."
45+
pr_number=$(gh pr list --state open --json number --search "$pr_name" -q '.[0].number')
46+
gh pr close "$pr_number" --delete-branch
47+
fi
5348
49+
git push --set-upstream origin "$branch_name"
50+
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
51+
else
52+
echo "No changes detected. Skipping PR creation."
53+
fi

0 commit comments

Comments
 (0)