From 8921098306fb63f620dfcf1e0b1bc75b6f749a30 Mon Sep 17 00:00:00 2001
From: Louis Moureaux <m_louis30@yahoo.com>
Date: Sun, 12 Feb 2023 02:19:25 +0100
Subject: [PATCH] Make the AutoRevision update PR against the tagged branch

We need to update AutoRevision.txt in both the stable and master branches, so
try to do that automatically.
---
 .github/workflows/release.yaml | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 222dba12ac..bc20336e7b 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -13,11 +13,20 @@ jobs:
       - run: git rev-parse --short=5 HEAD > cmake/AutoRevision.txt
       - run: git describe --tags `git rev-list --tags --max-count=1` >> cmake/AutoRevision.txt
       - run: cat cmake/AutoRevision.txt
+      - name: Find target branch
+        id: branch
+        # We're running on a tag so have no direct access to the branch. Find it.
+        # echo is used to trim whitespace
+        run: |
+          git branch -a
+          echo Target branch: $(git branch --contains HEAD)
+          echo branch=$(echo $(git branch --contains HEAD)) >> $GITHUB_OUTPUT
       - name: Create Pull Request
         uses: peter-evans/create-pull-request@v4.0.4
         with:
+          base: ${{ steps.branch.outputs.branch }}
           commit-message: "Release update of AutoRevision.txt"
-          branch: "release/autorevision"
+          branch: "release/autorevision-{{ steps.branch.outputs.target }}"
           title: "Release update of AutoRevision.txt"
           body: >
             Automatic changes triggered by a new release.