diff --git a/.github/workflows/workflow-ci.yaml b/.github/workflows/workflow-ci.yaml index c73995b..3b79ee2 100644 --- a/.github/workflows/workflow-ci.yaml +++ b/.github/workflows/workflow-ci.yaml @@ -83,8 +83,18 @@ jobs: # request two reviewers from OWNERS file randomly PR_NUMBER=${{ github.event.pull_request.number }} - REVIEWERS=$(yq '.reviewers[]' OWNERS | grep -v "^$AUTHOR$" | shuf | head -n 2 | paste -sd ",") - gh pr edit $PR_NUMBER --add-reviewer $REVIEWERS + REVIEWERS=$( + yq -r '.reviewers[]' OWNERS \ + | sed 's/^[ \t]*//;s/[ \t]*$//' \ + | tr -d '\r' \ + | grep -v "^${AUTHOR}$" \ + | shuf \ + | head -n 2 \ + | paste -sd "," + ) + if [ -n "$REVIEWERS" ]; then + gh pr edit $PR_NUMBER --add-reviewer "$REVIEWERS" + fi # Work for issue & PR, ignore update for now on-new-comment: @@ -167,13 +177,11 @@ jobs: # Handle hold command # hold/unhold the PR immediately in case of unexpected auto-merge. elif [[ "$COMMENT_LINE" =~ ^/hold ]]; then - if [[ "$LABEL" =~ ^cancel ]]; then - gh pr edit $ISSUE_NUMBER --remove-label do-not-merge/hold - echo "Remove label: do-not-merge/hold" - else - gh pr edit $ISSUE_NUMBER --add-label do-not-merge/hold - echo "Add label: do-not-merge/hold" - fi + gh pr edit $ISSUE_NUMBER --add-label do-not-merge/hold + echo "Add label: do-not-merge/hold" + elif [[ "$COMMENT_LINE" =~ ^/unhold ]]; then + gh pr edit $ISSUE_NUMBER --remove-label do-not-merge/hold + echo "Remove label: do-not-merge/hold" # Handle cc # Can not require review from the author. @@ -462,4 +470,4 @@ jobs: if [[ "$LABELS" == *"lgtm"* && "$LABELS" == *"approved"* && "$LABELS" != *"do-not-merge"* ]]; then gh pr merge $PR_NUMBER --squash echo "Auto merged" - fi + fi \ No newline at end of file