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(' ') + });