Skip to content

Commit 0ab6c87

Browse files
committed
Check for required inputs.
1 parent c056342 commit 0ab6c87

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

.github/workflows/backport.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,23 @@ on:
4545
permissions: {}
4646

4747
jobs:
48+
validate-inputs:
49+
name: Validate inputs
50+
runs-on: ubuntu-24.04
51+
steps:
52+
- name: Ensure a commit SHA or PR numbers are provided
53+
env:
54+
INPUTS_COMMIT_SHA: ${{ inputs.commit-sha }}
55+
INPUTS_PR_NUMBERS: ${{ inputs.pr_numbers }}
56+
run: |
57+
if [ -z "${INPUTS_COMMIT_SHA}" ] && [ -z "${INPUTS_PR_NUMBERS}" ]; then
58+
echo "::error::A commit SHA or PR number(s) must be included."
59+
exit 1
60+
fi
61+
4862
get-branches:
4963
name: Get target branches
64+
needs: [ 'validate-inputs' ]
5065
runs-on: ubuntu-24.04
5166
outputs:
5267
branches: ${{ steps.branches.outputs.result }}
@@ -82,7 +97,7 @@ jobs:
8297
8398
backport:
8499
name: 'Backport to ${{ matrix.branch }}'
85-
needs: [ 'get-branches' ]
100+
needs: [ 'validate-inputs', 'get-branches' ]
86101
if: ${{ needs.get-branches.outputs.branches != '[]' }}
87102
runs-on: ubuntu-24.04
88103
permissions:

0 commit comments

Comments
 (0)