From 7213379b93ce7fb5ae11e53310bf7d5c9727835d Mon Sep 17 00:00:00 2001 From: totoprayogo1916 Date: Tue, 19 Sep 2023 08:05:04 +0700 Subject: [PATCH] up --- .github/workflows/label-add-conflict.yml | 9 ++++++++- .github/workflows/label-remove-conflict.yml | 20 +++++--------------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/.github/workflows/label-add-conflict.yml b/.github/workflows/label-add-conflict.yml index 8cbc0cd142e9..e24b3bc6ff86 100644 --- a/.github/workflows/label-add-conflict.yml +++ b/.github/workflows/label-add-conflict.yml @@ -5,6 +5,10 @@ on: branches: - develop - '4.*' + pull_request: + branches: + - develop + - '4.*' jobs: auto-label-comment-conflict: @@ -15,9 +19,12 @@ jobs: runs-on: ubuntu-22.04 steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Get PR List id: PR-list - run: echo "pr_list=$(gh pr list -L 100 --json mergeable,url,labels,author)" >> $GITHUB_OUTPUT + run: echo "pr_list=$(gh pr list -L 100 --json mergeable,url,labels,author,statusCheckRollup)" >> $GITHUB_OUTPUT env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/label-remove-conflict.yml b/.github/workflows/label-remove-conflict.yml index cf1dcb881a16..d1b6c665322d 100644 --- a/.github/workflows/label-remove-conflict.yml +++ b/.github/workflows/label-remove-conflict.yml @@ -28,19 +28,9 @@ jobs: env: PR_DETAIL: ${{ steps.PR-detail.outputs.detail }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_URL: ${{ github.event.pull_request.html_url }} run: | - - IFS=$'\n' # Set Internal Field Separator to newline to handle array elements - - # Iterate through the PRs in PR_DETAIL - for pr in $(echo "$PR_DETAIL" | jq -c '.[]'); do - mergeable=$(echo "$pr" | jq -r '.mergeable') - author=$(echo "$pr" | jq -r '.author.login') - labels=$(echo "$pr" | jq -c '.labels[].name' | tr -d '[]"') - url=$(echo "$pr" | jq -r '.url') - - if [ "$mergeable" == "MERGEABLE" ] && [[ "$labels" == *"stale"* ]]; then - # Remove "stale" label - gh pr edit $url --add-label "stale" - fi - done + if [ "$(echo $PR_DETAIL | jq -r '.mergeable')" == "MERGEABLE" ] && \ + [ "$(echo $PR_DETAIL | jq -r '.labels[] | select(.name == "stale")')" != "" ]; then + gh pr edit $PR_URL --remove-label "stale" + fi