Skip to content

Commit

Permalink
backported-labels workflow: run on stable-* watching for merges, add …
Browse files Browse the repository at this point in the history
…backported-* label to backported PRs (#1025) (#1029)

Adding a workflow that updates a backported PR with a backported-* label once merged in a stable-* branch.
It's watching for commit messages ending with `foo (#123) (#456)`, and using the penultimate PR number, the format patchback uses.

Identical to the UI version ( ansible/ansible-hub-ui#428 )

No-Issue

(cherry picked from commit 825086d)

Co-authored-by: Martin Hradil <[email protected]>
  • Loading branch information
patchback[bot] and himdel authored Oct 14, 2021
1 parent fd61443 commit 6c6862c
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 6c6862c

Please sign in to comment.