Skip to content

Commit 86b209c

Browse files
committed
Create empty JUnit report branch if it doesn't exist
1 parent 6ca6cc4 commit 86b209c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

merge-junit-reports/action.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,26 @@ runs:
3333
shell: bash
3434
run: sudo apt update && sudo apt install -y xmlstarlet
3535

36-
- name: Checkout JUnit reports
36+
- name: Checkout repository
3737
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
3838
with:
3939
path: junit-reports
40-
ref: ${{ inputs.git-branch }}
41-
continue-on-error: true
40+
41+
- name: Create orphaned branch if checkout failed
42+
shell: bash
43+
working-directory: junit-reports
44+
run: |
45+
if git show-ref --verify --quiet refs/remotes/origin/${{ inputs.git-branch }}; then
46+
echo "Switching to branch ${{ inputs.git-branch }}"
47+
git switch ${{ inputs.git-branch }}
48+
else
49+
echo "Creating branch ${{ inputs.git-branch }}"
50+
git switch --orphan ${{ inputs.git-branch }}
51+
git config user.name "${{ github.actor }}"
52+
git config user.email "${{ github.actor }}@users.noreply.github.com"
53+
git commit --allow-empty -m "Initial commit for JUnit reports branch"
54+
git branch --set-upstream-to origin/${{ inputs.git-branch }}
55+
fi
4256
4357
- name: Merge JUnit report artifacts
4458
uses: actions/upload-artifact/merge@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4

0 commit comments

Comments
 (0)