4949 name : ${{ inputs.artifact-name }}
5050 path : ${{ inputs.artifact-path }}
5151
52+ - name : Checkout repository
53+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
54+ with :
55+ path : ${{ inputs.path }}
56+
5257 - name : Check JUnit reports SHA
5358 id : junit-reports-sha
5459 shell : bash
@@ -61,28 +66,44 @@ runs:
6166 if [ -f junit-reports-sha.txt ]; then
6267 UPLOAD_SHA_ARTIFACT=false
6368 CHECKOUT_REF=$(cat junit-reports-sha.txt)
69+ cd ${{ inputs.path }}
70+ echo "Checking out specific SHA: $CHECKOUT_REF"
71+ git fetch --quiet
72+ git checkout $CHECKOUT_REF
73+ else
74+ cd ${{ inputs.path }}
75+ if git ls-remote --exit-code --heads origin $CHECKOUT_REF; then
76+ echo "Switching to existing branch: $CHECKOUT_REF"
77+ git fetch --quiet
78+ git switch $CHECKOUT_REF
79+ else
80+ echo "Branch $CHECKOUT_REF does not exist, staying on default branch"
81+ UPLOAD_SHA_ARTIFACT=false
82+ fi
6483 fi
6584 else
6685 mkdir ${{ inputs.artifact-path }} || true
86+ cd ${{ inputs.path }}
87+ if git ls-remote --exit-code --heads origin $CHECKOUT_REF; then
88+ echo "Switching to existing branch: $CHECKOUT_REF"
89+ git fetch --quiet
90+ git switch $CHECKOUT_REF
91+ else
92+ echo "Branch $CHECKOUT_REF does not exist, staying on default branch"
93+ UPLOAD_SHA_ARTIFACT=false
94+ fi
6795 fi
6896 if [ "$UPLOAD_SHA_ARTIFACT" == "true" ]; then
69- echo "Checking out JUnit reports from branch $CHECKOUT_REF"
97+ echo "Will upload JUnit reports SHA for branch $CHECKOUT_REF"
7098 else
71- echo "Checking out JUnit reports from previously used SHA $CHECKOUT_REF "
99+ echo "Will not upload JUnit reports SHA"
72100 fi
73101 # we can only upload the artifact once, so only do this on the first split
74102 if [ "${{ inputs.split-index }}" != "0" ]; then
75103 echo "Skipping upload of JUnit reports SHA on this index"
76104 UPLOAD_SHA_ARTIFACT=false
77105 fi
78106 echo "upload-artifact=${UPLOAD_SHA_ARTIFACT}" >> "$GITHUB_OUTPUT"
79- echo "ref=${CHECKOUT_REF}" >> "$GITHUB_OUTPUT"
80-
81- - name : Checkout repository
82- uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
83- with :
84- path : ${{ inputs.path }}
85- ref : ${{ steps.junit-reports-sha.outputs.ref }}
86107
87108 - name : Save JUnit reports SHA
88109 if : ${{ steps.junit-reports-sha.outputs.upload-artifact == 'true' }}
0 commit comments