From 433643e9374561020c701afa2af505a65db19369 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Tue, 13 Jul 2021 15:35:28 +0000 Subject: [PATCH] Add backported-* label on stable-* merges (#428) (#633) * Add backported-* label on stable-* merges runs on push to a stable-* branch, takes the first line of the topmost commit message: Original PR title (#original PR number) (#backport PR number) extracts the first parenthesised PR number, as long as there are 2 and adds a backported-${branch number} label to the original PR * backported-labels: use actions-ecosystem/action-add-labels@v1 * backported-labels: remove deubgging bits (cherry picked from commit 2b61a8c00b6f8df6d3fa347f9017ef9cb49ca79a) Co-authored-by: Martin Hradil --- .github/workflows/backported-labels.yml | 32 +++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/backported-labels.yml diff --git a/.github/workflows/backported-labels.yml b/.github/workflows/backported-labels.yml new file mode 100644 index 0000000000..25fdb24593 --- /dev/null +++ b/.github/workflows/backported-labels.yml @@ -0,0 +1,32 @@ +name: 'Add backported-* labels' + +on: + # allow running manually + workflow_dispatch: + push: + branches: [ 'stable-*' ] + +jobs: + labels: + runs-on: ubuntu-latest + steps: + - name: 'Set $LABEL from branch name' + run: | + VERSION=`sed 's/^refs\/heads\/stable-//' <<< $GITHUB_REF` + LABEL="backported-${VERSION}" + echo "LABEL=${LABEL}" >> $GITHUB_ENV + + - uses: actions/checkout@v2 + + - name: 'Set $PR to PR number' + run: | + git log -1 --oneline + echo PR=`git log -1 --oneline | perl -ne 'print if s/^.*?\(#(\d+)\).*\(#\d+\).*$/$1/'` >> $GITHUB_ENV + + - name: "Add ${{ env.LABEL }} to #${{ env.PR }}" + if: ${{ env.PR }} + uses: actions-ecosystem/action-add-labels@v1 + with: + labels: ${{ env.LABEL }} + number: ${{ env.PR }} + github_token: ${{ secrets.GITHUB_TOKEN }}