From 08df69cc49de4e99ecd1439ca00433c7b6e6b4d1 Mon Sep 17 00:00:00 2001 From: omkarkhatavkar Date: Fri, 3 Nov 2023 18:23:35 +0530 Subject: [PATCH] add workflow to label cherry-pick versions on Pre-Commit-CI PRs --- .github/labels.yaml | 9 ++++++++ .github/workflows/pre_commit.yml | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 .github/labels.yaml create mode 100644 .github/workflows/pre_commit.yml diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 00000000..257588ce --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,9 @@ +--- +precommit-labels: + - 'CherryPick' + - '6.15.z' + - '6.14.z' + - '6.13.z' + - '6.12.z' + + diff --git a/.github/workflows/pre_commit.yml b/.github/workflows/pre_commit.yml new file mode 100644 index 00000000..75f47e5a --- /dev/null +++ b/.github/workflows/pre_commit.yml @@ -0,0 +1,38 @@ +name: add cherry-pick version labels to pre-commit-ci pr's + +on: + pull_request_target: + types: + - opened + - ready_for_review + - reopened + - synchronize + + +jobs: + add-labels: + runs-on: ubuntu-latest + if: github.actor == 'pre-commit-bot' + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Read labels from YAML + id: read-labels + run: | + LABELS=$(python3 -c "import yaml; print(' '.join(yaml.safe_load(open('./.github/labels.yaml'))['precommit-labels']))") + echo "name=LABELS" >> "$GITHUB_OUTPUT" + + - name: apply cherry-pick version labels. + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.CHERRYPICK_PAT }} + script: | + const labels = '${{ steps.read-labels.outputs.LABELS }}'; + const prNumber = '${{ github.event.number }}'; + github.rest.issues.addLabels({ + issue_number: prNumber, + owner: context.repo.owner, + repo: context.repo.repo, + labels: labels.split(' ') + });