From 6403642dd3378910687e023dc88e25a5ca112760 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 | 8 ++++++ .github/workflows/pre_commit_labels.yml | 37 +++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 .github/labels.yaml create mode 100644 .github/workflows/pre_commit_labels.yml diff --git a/.github/labels.yaml b/.github/labels.yaml new file mode 100644 index 00000000..03c119b8 --- /dev/null +++ b/.github/labels.yaml @@ -0,0 +1,8 @@ +--- +supported-branch-labels: + - 'CherryPick' + - '6.15.z' + - '6.14.z' + - '6.13.z' + - '6.12.z' + diff --git a/.github/workflows/pre_commit_labels.yml b/.github/workflows/pre_commit_labels.yml new file mode 100644 index 00000000..5283f025 --- /dev/null +++ b/.github/workflows/pre_commit_labels.yml @@ -0,0 +1,37 @@ +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'))['supported-branch-labels']))") + echo "LABELS=$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(' ') + });