From ccd6ea3261be45e7f88e38a17e3dffd0d7bf1d73 Mon Sep 17 00:00:00 2001 From: Asaf Joseph Gardin <39553475+Josephasafg@users.noreply.github.com> Date: Fri, 5 Jul 2024 17:59:20 +0300 Subject: [PATCH] ci: Update size label When PR size changes (#171) * ci: Update size label * test: File to test label * fix: Remove file --- .github/workflows/labeler.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index af744dcd..ad85867f 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -69,6 +69,36 @@ jobs: fi echo "label=$label" >> $GITHUB_ENV + - name: Fetch current labels + id: fetch_labels + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const { data: labels } = await github.issues.listLabelsOnIssue({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + }); + return labels.map(label => label.name); + + - name: Remove old size labels + id: remove_labels + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const sizeLabels = ['size:s', 'size:m', 'size:l', 'size:xl', 'size:xxl']; + const labelsToRemove = ${JSON.stringify(fetch_labels.outputs.labels)}.filter(label => sizeLabels.includes(label)); + for (const label of labelsToRemove) { + await github.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + name: label, + }); + } + - name: Add label to PR uses: actions-ecosystem/action-add-labels@v1 with: