From ca21ca9ba8d6e1a9fd98b2c1e2717e94d08fe97f Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Tue, 21 Nov 2023 09:54:21 -0800 Subject: [PATCH] feat: workflow dispatch for main merge workflow (#1649) --- .github/workflows/merge.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 42f572cef..e68d4b591 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -8,6 +8,12 @@ on: - '.graphics/**' - '.github/**' - '!.github/workflows/merge.yml' + workflow_dispatch: + inputs: + pr_no: + description: "PR-numbered container set to deploy" + type: number + required: true jobs: vars: @@ -41,14 +47,23 @@ jobs: - name: Get PR Number id: pr-number run: | - # Scrub last commit message for PR number - PR_NO=$(echo "${{ github.event.head_commit.message }}" | cut -d'#' -f 2 | cut -d')' -f 1) + # Get PR number from last commit or workflow_dispatch + if [ -z "${{ inputs.pr_no }}" ]; then + PR_NO=$(echo "${{ github.event.head_commit.message }}" \ + | head -n1 | cut -d'#' -f 2 | cut -d')' -f 1) + else + PR_NO=${{ inputs.pr_no }} + fi - # Echos - echo -e "pr=${PR_NO}" + # Validate PR_NO, exit on fail + echo -e "pr=${PR_NO} \n" echo -e "Last commit message: \n\t${{ github.event.head_commit.message }}" + if [ "${PR_NO}" =~ ^[0-9]+$ ]; then + echo "No PR number not found in commit message" + exit 1 + fi - # Send to GitHub Output + # If here, send to GitHub Output echo "pr=${PR_NO}" >> $GITHUB_OUTPUT # Add tag number and latest tags to PR image