From da6d6d117ab6dea76777adc7fd7dde75d9e2272c Mon Sep 17 00:00:00 2001 From: Simon Deziel Date: Thu, 28 Sep 2023 17:43:19 -0400 Subject: [PATCH] github: look for branch target name in PR title Signed-off-by: Simon Deziel --- .github/workflows/commits.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/commits.yml b/.github/workflows/commits.yml index 91d3c2667..022cf7e2f 100644 --- a/.github/workflows/commits.yml +++ b/.github/workflows/commits.yml @@ -26,9 +26,16 @@ jobs: - name: Check branch target env: TARGET: ${{ github.event.pull_request.base.ref }} + TITLE: ${{ github.event.pull_request.title }} run: | set -x - [ "${TARGET}" = "latest-edge" ] && exit 0 + TARGET_FROM_PR_TITLE="$(echo "${TITLE}" | sed -n 's/.*(\(\(latest\|[0-9]\.[0-9]\)-\(edge\|candidate\)\))$/\1/p')" + if [ -z "${TARGET_FROM_PR_TITLE}" ]; then + TARGET_FROM_PR_TITLE="latest-edge" + else + echo "Branch target overridden from PR title" + fi + [ "${TARGET}" = "${TARGET_FROM_PR_TITLE}" ] && exit 0 - echo "Invalid branch target: ${TARGET}" + echo "Invalid branch target: ${TARGET} != ${TARGET_FROM_PR_TITLE}" exit 1