From e1f865a0cb98d685197dfdb98abf1835c73c8c66 Mon Sep 17 00:00:00 2001 From: "ala'n (Alexey Stsefanovich)" Date: Fri, 17 Jan 2025 03:19:11 +0100 Subject: [PATCH] chore: update fix script to not lose output list --- .github/workflows/fix-labels.yml | 49 ++++++++++++++++---------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/.github/workflows/fix-labels.yml b/.github/workflows/fix-labels.yml index 1eefa52f9..930094f52 100644 --- a/.github/workflows/fix-labels.yml +++ b/.github/workflows/fix-labels.yml @@ -37,11 +37,12 @@ jobs: name: Access Denied run: exit 1 - - name: Find 'released on @beta' issues without 'released' label + - name: Find and fix 'released on @beta' issues without 'released' label id: find-issues uses: actions/github-script@v5 with: script: | + const update = core.getInput('update') === 'true'; const issues = await github.paginate(github.rest.issues.listForRepo, { owner: context.repo.owner, repo: context.repo.repo, @@ -50,28 +51,28 @@ jobs: }); const issuesWithoutReleasedLabel = issues.filter(issue => !issue.labels.some(label => label.name === 'released')); console.log('Found %d issues without "released" label', issuesWithoutReleasedLabel.length); - console.log('Issues without "released" label: ', issuesWithoutReleasedLabel.map(issue => '#' + issue.number).join(', ')); - core.setOutput('issuesWithoutReleasedLabel', JSON.stringify(issuesWithoutReleasedLabel.map(issue => issue.number))); - - name: Add 'released' label to issues - if: steps.find-issues.outputs.issuesWithoutReleasedLabel && inputs.update - uses: actions/github-script@v5 - with: - script: | - const issues = JSON.parse(core.getInput('issuesWithoutReleasedLabel')); - for (const issue of issues) { - console.log(`Adding 'released' label to issue #${issue}`); - await github.rest.issues.addLabels({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue, - labels: ['released'] - }); - console.log(`Removing 'released on @beta' label from issue #${issue}`); - await github.rest.issues.removeLabel({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue, - name: 'released on @beta' - }); + // Log just first 15 issues + const issuesToLog = issuesWithoutReleasedLabel.slice(0, 15); + console.log('Here is some of them: ', issuesToLog.map(issue => '#' + issue.number).join(', ')); + + if (update) { + for (const issue of issues) { + console.log(`Adding 'released' label to issue #${issue}`); + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue, + labels: ['released'] + }); + console.log(`Removing 'released on @beta' label from issue #${issue}`); + await github.rest.issues.removeLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue, + name: 'released on @beta' + }); + } + } else { + console.log('Was run in dry-run mode, no changes were made'); }