diff --git a/.github/workflows/parent-pipeline.yml b/.github/workflows/parent-pipeline.yml index 2dd41e7..53f2c5d 100644 --- a/.github/workflows/parent-pipeline.yml +++ b/.github/workflows/parent-pipeline.yml @@ -21,12 +21,29 @@ jobs: - id: determine name: Extract Branch and Event run: | - echo "Extracting branch and event context..." - branch=$(echo "${{ github.ref_name }}" - echo "Branch Name: $branch" - echo "Event Name: ${{ github.event_name }}" - echo "branch_name=$branch" >> $GITHUB_OUTPUT - echo "event_name=${{ github.event_name }}" >> $GITHUB_OUTPUT + echo "Extracting branch and event context..." + + # Extract branch name based on ref type + if [[ "${{ github.ref }}" == refs/heads/* ]]; then + branch_name="${{ github.ref#refs/heads/ }}" # Strip refs/heads/ + elif [[ "${{ github.ref }}" == refs/pull/* ]]; then + branch_name="pull_request_${{ github.event.pull_request.number }}" # Handle pull requests + elif [[ "${{ github.ref }}" == refs/tags/* ]]; then + branch_name="${{ github.ref#refs/tags/ }}" # Handle tags + else + branch_name="${{ github.ref }}" # Default to raw ref + fi + + echo "Branch Name: $branch_name" + echo "Event Name: ${{ github.event_name }}" + + # Set outputs + echo "branch_name=$branch_name" >> $GITHUB_OUTPUT + echo "event_name=${{ github.event_name }}" >> $GITHUB_OUTPUT + + # Set outputs + echo "branch_name=$branch_name" >> $GITHUB_OUTPUT + echo "event_name=${{ github.event_name }}" >> $GITHUB_OUTPUT - name: Debug Branch Name run: | echo "Extracted Branch Name: ${{ needs.determine-workflow.outputs.branch_name }}"