Skip to content

Commit 26065da

Browse files
committed
Create empty JUnit report branch if it doesn't exist
1 parent ee58a9e commit 26065da

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

merge-junit-reports/action.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,30 @@ runs:
3131
steps:
3232
- name: Set up xmlstarlet
3333
shell: bash
34-
run: sudo apt update && sudo apt install -y xmlstarlet
34+
run: |
35+
sudo apt update
36+
sudo apt install -y xmlstarlet
3537
36-
- name: Checkout JUnit reports
38+
- name: Checkout repository
3739
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3840
with:
3941
path: junit-reports
40-
ref: ${{ inputs.git-branch }}
41-
continue-on-error: true
42+
43+
- name: Create orphaned branch if checkout failed
44+
shell: bash
45+
working-directory: junit-reports
46+
run: |
47+
if git show-ref --verify --quiet refs/remotes/origin/${{ inputs.git-branch }}; then
48+
echo "Switching to branch ${{ inputs.git-branch }}"
49+
git switch ${{ inputs.git-branch }}
50+
else
51+
echo "Creating branch ${{ inputs.git-branch }}"
52+
git switch --orphan ${{ inputs.git-branch }}
53+
git config user.name "${{ github.actor }}"
54+
git config user.email "${{ github.actor }}@users.noreply.github.com"
55+
git commit --allow-empty -m "Initial commit for JUnit reports branch"
56+
git push origin --set-upstream ${{ inputs.git-branch }}
57+
fi
4258
4359
- name: Merge JUnit report artifacts
4460
uses: actions/upload-artifact/merge@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4

0 commit comments

Comments
 (0)