Skip to content

Commit db7b634

Browse files
author
Pelle Wessman
committed
Add a create-branch-if-needed option
1 parent 2c7d010 commit db7b634

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

.github/workflows/reusable-sync.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ on:
8080
required: false
8181
default: 'lts/*'
8282
type: string
83+
create-branch-if-needed:
84+
description: 'Create a branch if one is missing'
85+
required: false
86+
default: true
87+
type: boolean
8388

8489
permissions:
8590
contents: write
@@ -181,10 +186,12 @@ jobs:
181186
git config --global user.email "${{ inputs.commit-email }}"
182187
git checkout -b ${{ inputs.branch-name }}
183188
git add .
184-
if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then
185-
echo "createPR=true" >> $GITHUB_OUTPUT
186-
git commit -m "${{ inputs.commit-message }}"
187-
git push origin ${{ inputs.branch-name }} -fu --no-verify
189+
if ${{ inputs.create-branch-if-needed }} || (git show-ref origin/${{ inputs.branch-name }} -q); then
190+
if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then
191+
echo "createPR=true" >> $GITHUB_OUTPUT
192+
git commit -m "${{ inputs.commit-message }}"
193+
git push origin ${{ inputs.branch-name }} -fu --no-verify
194+
fi
188195
fi
189196
fi
190197

0 commit comments

Comments
 (0)