Skip to content

Commit

Permalink
Add a create-branch-if-needed option
Browse files Browse the repository at this point in the history
  • Loading branch information
Pelle Wessman committed Feb 28, 2023
1 parent 2c7d010 commit db7b634
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions .github/workflows/reusable-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ on:
required: false
default: 'lts/*'
type: string
create-branch-if-needed:
description: 'Create a branch if one is missing'
required: false
default: true
type: boolean

permissions:
contents: write
Expand Down Expand Up @@ -181,10 +186,12 @@ jobs:
git config --global user.email "${{ inputs.commit-email }}"
git checkout -b ${{ inputs.branch-name }}
git add .
if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then
echo "createPR=true" >> $GITHUB_OUTPUT
git commit -m "${{ inputs.commit-message }}"
git push origin ${{ inputs.branch-name }} -fu --no-verify
if ${{ inputs.create-branch-if-needed }} || (git show-ref origin/${{ inputs.branch-name }} -q); then
if (! git show-ref origin/${{ inputs.branch-name }} -q) || [[ "$(git diff origin/${{ inputs.branch-name }} --stat)" != "" ]]; then
echo "createPR=true" >> $GITHUB_OUTPUT
git commit -m "${{ inputs.commit-message }}"
git push origin ${{ inputs.branch-name }} -fu --no-verify
fi
fi
fi
Expand Down

0 comments on commit db7b634

Please sign in to comment.