Skip to content

Commit

Permalink
fix: add conditions for empty LABELS (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
flukolo4ek authored Oct 15, 2024
1 parent d7dff0d commit ddcbac6
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,42 @@ jobs:
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

e2e-no-labels:
runs-on: ubuntu-20.04
needs: e2e-default

permissions:
pull-requests: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Test Run
id: test-run
uses: ./
with:
github_pr_title: "fix: esli b mishki bili b pchelami"

- name: Get labels
id: get-labels
run: ./src/labels/get.sh
env:
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Assert placeholder
uses: nick-fields/assert-action@v2
with:
actual: ${{ steps.get-labels.outputs.labels }}
expected: |
type/fix
- name: Delete all labels
run: ./src/labels/delete_all.sh
env:
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.number }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ runs:
- name: Add labels
shell: bash
run: ${{ github.action_path }}/src/labels/add_multiple.sh
if: ${{ steps.construct_labels.outputs.labels_to_add != '' }}
env:
LABELS: ${{ steps.construct_labels.outputs.labels_to_add }}
REPO: ${{ inputs.github_owner }}/${{ inputs.github_repo }}
Expand All @@ -50,6 +51,7 @@ runs:
- 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 }}
Expand Down
6 changes: 4 additions & 2 deletions src/construct_labels.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
# shellcheck source=src/common.sh
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"

CURRENT_LABELS=${CURRENT_LABELS}
CURRENT_LABELS="${CURRENT_LABELS:-""}"
PR_TITLE=${PR_TITLE}

CONFIG_JSON="https://raw.githubusercontent.com/datalens-tech/datalens/main/.github/workflows/scripts/changelog/changelog_config.json"
Expand All @@ -14,7 +14,9 @@ CONFIG_DATA=$(curl -s "$CONFIG_JSON")
TYPE_LABELS_PREFIX=$(echo "$CONFIG_DATA" | jq -r '.section_tags.prefix')
COMPONENT_LABELS_PREFIX=$(echo "$CONFIG_DATA" | jq -r '.component_tags.prefix')

CURRENT_LABELS=$(echo "${CURRENT_LABELS}" | grep -E "$TYPE_LABELS_PREFIX|$COMPONENT_LABELS_PREFIX" | sort)
if [[ -n $CURRENT_LABELS ]]; then
CURRENT_LABELS=$(echo "$CURRENT_LABELS" | grep -E "$TYPE_LABELS_PREFIX|$COMPONENT_LABELS_PREFIX" | sort)
fi

LABELS_SECTION=${PR_TITLE%%:*}
COMMIT_TYPE=${LABELS_SECTION%%\(*}
Expand Down

0 comments on commit ddcbac6

Please sign in to comment.