From f89a2b4421a502a672d6fc53db94ea06fd4fcc1d Mon Sep 17 00:00:00 2001 From: Lesigh-3100 Date: Sun, 21 Apr 2024 15:02:04 +0300 Subject: [PATCH] Update release-and-pypi-publish.yml --- .../workflows/release-and-pypi-publish.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/release-and-pypi-publish.yml b/.github/workflows/release-and-pypi-publish.yml index 3aa4a218b..6c760eae2 100644 --- a/.github/workflows/release-and-pypi-publish.yml +++ b/.github/workflows/release-and-pypi-publish.yml @@ -100,6 +100,35 @@ jobs: git tag $NEW_VERSION git push origin main --tags + - name: Label linked issues as merged + if: github.event.pull_request.merged == true && github.ref == 'refs/heads/main' + uses: actions/github-script@v5 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const github = require('@actions/github'); + const context = github.context; + const pullRequest = context.payload.pull_request; + + // Regex to extract linked issue numbers from PR body + const issueRegex = /(?:fixes|resolves|closes) #(\d+)/gi; + let match; + const issueNumbers = []; + + while ((match = issueRegex.exec(pullRequest.body)) !== null) { + issueNumbers.push(match[1]); + } + + // Add a label to each linked issue + for (const issueNumber of issueNumbers) { + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issueNumber, + labels: ['merged to main'] + }); + } + - name: Generate changelog if: steps.check.outputs.skip != 'true' uses: heinrichreimer/github-changelog-generator-action@v2.3