Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
| ... | ... |
@@ -44,3 +44,19 @@ jobs: |
| 44 | 44 |
|
| 45 | 45 |
echo "This PR will be included in the release notes with the following note:" |
| 46 | 46 |
echo "$desc" |
| 47 |
+ |
|
| 48 |
+ check-pr-branch: |
|
| 49 |
+ runs-on: ubuntu-20.04 |
|
| 50 |
+ env: |
|
| 51 |
+ PR_TITLE: ${{ github.event.pull_request.title }}
|
|
| 52 |
+ steps: |
|
| 53 |
+ # Backports or PR that target a release branch directly should mention the target branch in the title, for example: |
|
| 54 |
+ # [X.Y backport] Some change that needs backporting to X.Y |
|
| 55 |
+ # [X.Y] Change directly targeting the X.Y branch |
|
| 56 |
+ - name: Get branch from PR title |
|
| 57 |
+ id: title_branch |
|
| 58 |
+ run: echo "$PR_TITLE" | sed -n 's/^\[\([0-9]*\.[0-9]*\)[^]]*\].*/branch=\1/p' >> $GITHUB_OUTPUT |
|
| 59 |
+ |
|
| 60 |
+ - name: Check release branch |
|
| 61 |
+ if: github.event.pull_request.base.ref != steps.title_branch.outputs.branch && !(github.event.pull_request.base.ref == 'master' && steps.title_branch.outputs.branch == '') |
|
| 62 |
+ run: echo "::error::PR title suggests targetting the ${{ steps.title_branch.outputs.branch }} branch, but is opened against ${{ github.event.pull_request.base.ref }}" && exit 1
|