From d751fd023717af7c426455406d176aafd7304c56 Mon Sep 17 00:00:00 2001 From: flukolo4ek Date: Thu, 17 Oct 2024 11:39:30 +0300 Subject: [PATCH] fix: gh cli -> gh api --- .github/workflows/e2e.yaml | 2 ++ action.yaml | 12 +----------- src/construct_labels.sh | 5 +++-- src/labels/add_multiple.sh | 11 ----------- src/labels/delete_multiple.sh | 11 ----------- 5 files changed, 6 insertions(+), 35 deletions(-) delete mode 100755 src/labels/add_multiple.sh delete mode 100755 src/labels/delete_multiple.sh diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 6eb7904..f463228 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -27,6 +27,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LABELS: | bug + duplicate type/fix type/feat component/embeds @@ -55,6 +56,7 @@ jobs: bug component/auth component/docs + duplicate type/fix - name: Delete all labels diff --git a/action.yaml b/action.yaml index af15664..88b1f96 100644 --- a/action.yaml +++ b/action.yaml @@ -40,7 +40,7 @@ runs: - name: Add labels shell: bash - run: ${{ github.action_path }}/src/labels/add_multiple.sh + run: ${{ github.action_path }}/src/labels/set.sh if: ${{ steps.construct_labels.outputs.labels_to_add != '' }} env: LABELS: ${{ steps.construct_labels.outputs.labels_to_add }} @@ -48,16 +48,6 @@ runs: PR_NUMBER: ${{ inputs.github_pr_number }} GH_TOKEN: ${{ inputs.github_token }} - - name: Delete labels - shell: bash - run: ${{ github.action_path }}/src/labels/delete_multiple.sh - if: ${{ steps.construct_labels.outputs.labels_to_delete != '' }} - env: - LABELS: ${{ steps.construct_labels.outputs.labels_to_delete }} - PR_NUMBER: ${{ inputs.github_pr_number }} - REPO: ${{ inputs.github_owner }}/${{ inputs.github_repo }} - GH_TOKEN: ${{ inputs.github_token }} - branding: icon: "tag" color: "gray-dark" diff --git a/src/construct_labels.sh b/src/construct_labels.sh index 0ff1c1b..2d86a65 100755 --- a/src/construct_labels.sh +++ b/src/construct_labels.sh @@ -6,6 +6,7 @@ set -euo pipefail source "$(dirname "${BASH_SOURCE[0]}")/common.sh" CURRENT_LABELS="${CURRENT_LABELS:-""}" +OTHER_LABELS="" PR_TITLE=${PR_TITLE} CONFIG_JSON="https://raw.githubusercontent.com/datalens-tech/datalens/main/.github/workflows/scripts/changelog/changelog_config.json" @@ -15,6 +16,7 @@ TYPE_LABELS_PREFIX=$(echo "$CONFIG_DATA" | jq -r '.section_tags.prefix') COMPONENT_LABELS_PREFIX=$(echo "$CONFIG_DATA" | jq -r '.component_tags.prefix') if [[ -n $CURRENT_LABELS ]]; then + OTHER_LABELS=$(echo "$CURRENT_LABELS" | grep -Ev "$TYPE_LABELS_PREFIX|$COMPONENT_LABELS_PREFIX" | sort) CURRENT_LABELS=$(echo "$CURRENT_LABELS" | grep -E "$TYPE_LABELS_PREFIX|$COMPONENT_LABELS_PREFIX" | sort) fi @@ -29,8 +31,7 @@ if [[ -n $COMPONENT_SECTION ]]; then LABELS_TO_ADD+="\n$COMMIT_COMPONENTS" fi +LABELS_TO_ADD+="\n$OTHER_LABELS" LABELS_TO_ADD=$(echo -e "$LABELS_TO_ADD" | sort) -LABELS_TO_DELETE=$(comm -13 <(echo "$LABELS_TO_ADD") <(echo "$CURRENT_LABELS")) set_output "labels_to_add" "$LABELS_TO_ADD" -set_output "labels_to_delete" "$LABELS_TO_DELETE" diff --git a/src/labels/add_multiple.sh b/src/labels/add_multiple.sh deleted file mode 100755 index 49f3b95..0000000 --- a/src/labels/add_multiple.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -LABELS=${LABELS} -REPO=${REPO} -PR_NUMBER=${PR_NUMBER} - -gh pr edit "$PR_NUMBER" \ - --repo "$REPO" \ - --add-label "$(echo "$LABELS" | tr '\n' ',' | sed 's/,$//')" diff --git a/src/labels/delete_multiple.sh b/src/labels/delete_multiple.sh deleted file mode 100755 index f593806..0000000 --- a/src/labels/delete_multiple.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -LABELS=${LABELS} -REPO=${REPO} -PR_NUMBER=${PR_NUMBER} - -gh pr edit "$PR_NUMBER" \ - --repo "$REPO" \ - --remove-label "$(echo "$LABELS" | tr '\n' ',' | sed 's/,$//')"