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