Skip to content

Commit 03fc16d

Browse files
committed
only create pr if required
1 parent a482f2f commit 03fc16d

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

.github/workflows/dependency-checker.yaml

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,24 @@ jobs:
3030
make update-dependencies
3131
branch_name="dependency-updater-${{ github.run_id }}"
3232
git checkout -b "$branch_name"
33-
for file in $(git diff --name-only | grep poetry.lock); do
34-
# Extract the service for which the dependencies have been updated
35-
dirpath=$(dirname $file)
3633
37-
# Create PR
38-
git add "$file"
39-
git commit -m "chore: dependency update"
40-
done
41-
42-
# Check if a PR already exists for the package
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
48-
49-
git push --set-upstream origin "$branch_name"
50-
gh pr create --title "$pr_name" --body "Automated dependency update" --base "main"
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 the package
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
5148
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)