From 094d5e90904f89ca88a1ec014397dbad3a660481 Mon Sep 17 00:00:00 2001 From: Silabs-ThieuVu <65759766+Silabs-ThieuVu@users.noreply.github.com> Date: Wed, 16 Oct 2024 10:31:13 +0700 Subject: [PATCH] Update 02-Run_Unit_Test.yaml --- .github/workflows/02-Run_Unit_Test.yaml | 44 ++++++++++++++++--------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/.github/workflows/02-Run_Unit_Test.yaml b/.github/workflows/02-Run_Unit_Test.yaml index c4026288..d551666b 100644 --- a/.github/workflows/02-Run_Unit_Test.yaml +++ b/.github/workflows/02-Run_Unit_Test.yaml @@ -40,17 +40,23 @@ jobs: - name: Check Branch Input run: | - if [ -z "${{ github.event.inputs.branch }}" ]; then - echo "Branch input is required." - exit 1 + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ -z "${{ github.event.inputs.branch }}" ]; then + echo "Branch input is required for manual trigger." + exit 1 + else + echo "Checkout branch ${{ github.event.inputs.branch }}" + fi + else + # Extract branch name from github.ref + BRANCH_NAME="${{ github.ref }}" + BRANCH_NAME="${BRANCH_NAME##*/}" # This removes everything before the last '/' + echo "Checkout branch $BRANCH_NAME" fi - echo "Checkout branch ${{ github.event.inputs.branch }}" - name: Checkout - uses: actions/checkout@v4.1.7 - with: - ref: "${{ github.event.inputs.branch }}" - + uses: actions/checkout@v4.1.7 + - name: Add extension run: | cd $SDK_PATH @@ -123,17 +129,23 @@ jobs: - name: Check Branch Input run: | - if [ -z "${{ github.event.inputs.branch }}" ]; then - echo "Branch input is required." - exit 1 + if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then + if [ -z "${{ github.event.inputs.branch }}" ]; then + echo "Branch input is required for manual trigger." + exit 1 + else + echo "Checkout branch ${{ github.event.inputs.branch }}" + fi + else + # Extract branch name from github.ref + BRANCH_NAME="${{ github.ref }}" + BRANCH_NAME="${BRANCH_NAME##*/}" # This removes everything before the last '/' + echo "Checkout branch $BRANCH_NAME" fi - echo "Checkout branch ${{ github.event.inputs.branch }}" - name: Checkout - uses: actions/checkout@v4.1.7 - with: - ref: "${{ github.event.inputs.branch }}" - + uses: actions/checkout@v4.1.7 + - name: Add extension run: | cd $SDK_PATH