diff --git a/.github/workflows/dependency-checker.yaml b/.github/workflows/dependency-checker.yaml index 9f4e61f89..b9f57ddfb 100644 --- a/.github/workflows/dependency-checker.yaml +++ b/.github/workflows/dependency-checker.yaml @@ -32,18 +32,22 @@ jobs: # Check if a PR already exists for the package if gh pr list --state open | grep -q "${pr_name}"; then - echo "Pr for $dirpath already exists. Skipping." - else - # Create PR - branch_name="dependency-updater-$dirpath" - git checkout -b "$branch_name" - git add "$file" - git commit -m "chore: dependency update" - git push --set-upstream origin "$branch_name" - echo $(git status) - gh pr create --title "$pr_name" --body "Automated dependency update" --base "main" - git checkout main - sleep 30 # prevent rate limit. - fi + 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 + + # Create PR + branch_name="dependency-updater-$dirpath-${{ github.run_id }}" + git checkout -b "$branch_name" + git add "$file" + git commit -m "chore: dependency update" + git push --set-upstream origin "$branch_name" + echo $(git status) + gh pr create --title "$pr_name" --body "Automated dependency update" --base "main" + git checkout main + sleep 30 # prevent rate limit. + done