Skip to content

Commit

Permalink
Add --no-run-if-empty option to xargs command
Browse files Browse the repository at this point in the history
Without this option, xargs will run the `gh pr close` command with
no arguments when `gh pr list` outputs no PRs. Adding this option
prevents the error that can result.
  • Loading branch information
adamkpickering committed Mar 11, 2024
1 parent 2367f1f commit b224e06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/update-main-source.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
# close all existing PRs from branches starting with "auto-update"
gh pr --repo "$GITHUB_REPOSITORY" list --search 'head:auto-update' --json 'headRefName' --jq '.[] | join("\n")' | \
xargs -n 1 gh pr --repo "$GITHUB_REPOSITORY" close
xargs --no-run-if-empty -n 1 gh pr --repo "$GITHUB_REPOSITORY" close
# push changes
git push --set-upstream origin "$BRANCH"
Expand Down

0 comments on commit b224e06

Please sign in to comment.