Skip to content

Commit

Permalink
Add backported-* label on stable-* merges (#428) (#633)
Browse files Browse the repository at this point in the history
* 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 2b61a8c)

Co-authored-by: Martin Hradil <[email protected]>
  • Loading branch information
patchback[bot] and himdel authored Jul 13, 2021
1 parent 3de5068 commit 433643e
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/backported-labels.yml
Original file line number Diff line number Diff line change
@@ -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 }}

0 comments on commit 433643e

Please sign in to comment.